acer

32632 Reputation

29 Badges

20 years, 45 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Mac Dude Yes, that is why I asked before, for clarification. Augmenting with specific nonzero data can also be done easily (but in other ways).

Note that your question still has a few vague aspects. To augment from 4x4 to 7x7 and fill in all the new entries with specific nonzero data entails more than just one new Matrix. (...unless you intend to mask the old, onto the new.)

Here is one way, by calling the Matrix() constructor. This is just one possibility (involving three new submatrices of the final result) amongst several, because of the remaining ambiguity as to your precise intent.

M:=Matrix(4,4,(i,j)->orig);

                             [orig  orig  orig  orig]
                             [                      ]
                             [orig  orig  orig  orig]
                        M := [                      ]
                             [orig  orig  orig  orig]
                             [                      ]
                             [orig  orig  orig  orig]

T1:=Matrix(4,3,(i,j)->new1):
T2:=Matrix(3,4,(i,j)->new2):
T3:=Matrix(3,3,(i,j)->new3):

Matrix([[M,T1],[T2,T3]]);

                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [new2  new2  new2  new2  new3  new3  new3]
                 [                                        ]
                 [new2  new2  new2  new2  new3  new3  new3]
                 [                                        ]
                 [new2  new2  new2  new2  new3  new3  new3]

You could also use the angle-bracket constructors to get the same result, and so use a terser input command. You could also create the new 7x7 Matrix as empty, and then use indexing operations to write all the submatrices into it.

@Mac Dude Yes, that is why I asked before, for clarification. Augmenting with specific nonzero data can also be done easily (but in other ways).

Note that your question still has a few vague aspects. To augment from 4x4 to 7x7 and fill in all the new entries with specific nonzero data entails more than just one new Matrix. (...unless you intend to mask the old, onto the new.)

Here is one way, by calling the Matrix() constructor. This is just one possibility (involving three new submatrices of the final result) amongst several, because of the remaining ambiguity as to your precise intent.

M:=Matrix(4,4,(i,j)->orig);

                             [orig  orig  orig  orig]
                             [                      ]
                             [orig  orig  orig  orig]
                        M := [                      ]
                             [orig  orig  orig  orig]
                             [                      ]
                             [orig  orig  orig  orig]

T1:=Matrix(4,3,(i,j)->new1):
T2:=Matrix(3,4,(i,j)->new2):
T3:=Matrix(3,3,(i,j)->new3):

Matrix([[M,T1],[T2,T3]]);

                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [orig  orig  orig  orig  new1  new1  new1]
                 [                                        ]
                 [new2  new2  new2  new2  new3  new3  new3]
                 [                                        ]
                 [new2  new2  new2  new2  new3  new3  new3]
                 [                                        ]
                 [new2  new2  new2  new2  new3  new3  new3]

You could also use the angle-bracket constructors to get the same result, and so use a terser input command. You could also create the new 7x7 Matrix as empty, and then use indexing operations to write all the submatrices into it.

I don't recall who wrote that Strip procedure. But I believe that it's original purpose was for stripping off trailing zeroes, no?

I felt I should mention that, lest anyone wrongly imagine that it was written to fix the behaviour that you're talking about in this thread.

The Strip proc does turn 1.0 and 1. into exact integer 1, and it turns 3.0 and 3. into exact 3 as well. I'd call that a bug in Strip, if it was intended just for stripping off trailing zeroes!

Strip := Z -> subsindets( Z, {float}, z -> parse(sprintf("%g",z)) ):

x := -1.*2.0^b;

                                            b
                                x := -1. 2.0 

Strip(x); # not appropriate!

                                       b
                                     -2 

acer

I don't recall who wrote that Strip procedure. But I believe that it's original purpose was for stripping off trailing zeroes, no?

I felt I should mention that, lest anyone wrongly imagine that it was written to fix the behaviour that you're talking about in this thread.

The Strip proc does turn 1.0 and 1. into exact integer 1, and it turns 3.0 and 3. into exact 3 as well. I'd call that a bug in Strip, if it was intended just for stripping off trailing zeroes!

Strip := Z -> subsindets( Z, {float}, z -> parse(sprintf("%g",z)) ):

x := -1.*2.0^b;

                                            b
                                x := -1. 2.0 

Strip(x); # not appropriate!

                                       b
                                     -2 

acer

@ambitiousad The eight equations in s1 are explicit equations with the members of [Ana, Anm, Anr, Ans, Bna, Bnm, Bno, Bns] on the left-hand-sides.

If you can solve for the (introduced) alpha[i] variables, then their explicit solutions can be resubstituted back into s1.

@ambitiousad The eight equations in s1 are explicit equations with the members of [Ana, Anm, Anr, Ans, Bna, Bnm, Bno, Bns] on the left-hand-sides.

If you can solve for the (introduced) alpha[i] variables, then their explicit solutions can be resubstituted back into s1.

@mc123 

In Maple 16 the thickness of the gridlines can be set independently of the thickness of the axes.

plot(sin(x),x=0..4,axis=[gridlines=[thickness=1],thickness=4]);

 

Tickmarks are another issue, however.

acer

@mc123 

In Maple 16 the thickness of the gridlines can be set independently of the thickness of the axes.

plot(sin(x),x=0..4,axis=[gridlines=[thickness=1],thickness=4]);

 

Tickmarks are another issue, however.

acer

It's not generally well known, these days, just how much Georg Ohm looked like Rudolph Diesel.

@herclau Try this (Linux/Unix file/directory paths, similar to your code),

with(ImageTools):

plotsetup(default);

img := Matrix(ToGrayscale(Read(cat(kernelopts(datadir),
                                   "/images/FingerPrint.jpg")))):

vsize,hsize:=op(1,img);

P:=plots:-textplot([1, .5, "take from A"], align = {above, right},
                   font = [TIMES,ROMAN,16], axes = none):

plotsetup('jpeg','plotoutput'="text1.jpg",
          'plotoptions'=cat("height=",vsize+6+4,",width=",hsize+5+5));

P; # Wait until this gets exported and written to OS! How long? It depends...

Threads:-Sleep(3): # This waits long enough, on my host. YMMV.

T := Read("text1.jpg"):

correctedT := rtable_redim(T[1+6 .. (-1)-4,
                           1+5 .. (-1)-5, 1 .. -1],
                           1 .. vsize, 1 .. hsize, 1 .. 3):

View(correctedT);

newQ := ImageTools:-Mask(img, ToGrayscale(correctedT)):

View(newQ);

I made a change to mask with ToGrayscale(correctedT), because your example uses a gray scale image for the background.

@herclau Try this (Linux/Unix file/directory paths, similar to your code),

with(ImageTools):

plotsetup(default);

img := Matrix(ToGrayscale(Read(cat(kernelopts(datadir),
                                   "/images/FingerPrint.jpg")))):

vsize,hsize:=op(1,img);

P:=plots:-textplot([1, .5, "take from A"], align = {above, right},
                   font = [TIMES,ROMAN,16], axes = none):

plotsetup('jpeg','plotoutput'="text1.jpg",
          'plotoptions'=cat("height=",vsize+6+4,",width=",hsize+5+5));

P; # Wait until this gets exported and written to OS! How long? It depends...

Threads:-Sleep(3): # This waits long enough, on my host. YMMV.

T := Read("text1.jpg"):

correctedT := rtable_redim(T[1+6 .. (-1)-4,
                           1+5 .. (-1)-5, 1 .. -1],
                           1 .. vsize, 1 .. hsize, 1 .. 3):

View(correctedT);

newQ := ImageTools:-Mask(img, ToGrayscale(correctedT)):

View(newQ);

I made a change to mask with ToGrayscale(correctedT), because your example uses a gray scale image for the background.

@herclau What dimensions did you use for creating text1.jpg?

Before I applied `redim`, I created my "text" jpg image file in this way,

plotsetup('jpeg','plotoutput'=tempfile,'plotoptions'=cat("height=",vsize+6+4,
                                                         ",width=",hsize+5+5));

What I was trying to do was to stretch the "text" image, when exporting it, by some amounts that would (hopefully) match the whitespace borders. Above, vsize and hsize are the dimensions of the background image onto which I overlaid the "text" image.

Maybe you could attach your sample image and text plot command that you want, and we could work out the commands in full.

@herclau What dimensions did you use for creating text1.jpg?

Before I applied `redim`, I created my "text" jpg image file in this way,

plotsetup('jpeg','plotoutput'=tempfile,'plotoptions'=cat("height=",vsize+6+4,
                                                         ",width=",hsize+5+5));

What I was trying to do was to stretch the "text" image, when exporting it, by some amounts that would (hopefully) match the whitespace borders. Above, vsize and hsize are the dimensions of the background image onto which I overlaid the "text" image.

Maybe you could attach your sample image and text plot command that you want, and we could work out the commands in full.

The cited reference seems more about a different problem, of optimizing parameters appearing in the IVP.

One thing to be careful about, if calling fsolve (or another rootfinder) for this task, is ensuring that the appropriate range of the independent variable (t) is used.

A slightly different target value for y(t) in Markiyan's example can illustrate this,

sys := (D(x))(t) = y(t)-x(t), (D(y))(t) = x(t)*(D(x))(t)-2*y(t):
ic := x(0) = 1, y(0) = -1:
sol := dsolve({ic, sys}, numeric):

fsolve('t ->rhs(sol(t)[3])-(-0.85) ');

                         -0.2029134387

fsolve('t ->rhs(sol(t)[3])-(-0.85) ', 0..infinity);

                          0.2639507984

acer

First 408 409 410 411 412 413 414 Last Page 410 of 597