Items tagged with convert convert Tagged Items Feed

I want to apologize if this being neither necessarily a minimal working example for one question nor just one question is uncomfortable. The "MWE" was created on and is designed for Linux machines including ImageMagick. The problem itself should be obvious to all users though, as the subfolder and creation of the gif are just conveniences. I have three sections concerning the different problems occuring in my attempts.

(which I was told is not doable in maple ... hence the gif)

link

The goal was to create an animation that zooms in on a function. As maple just wouldn't allow scaling of axis in animations I decided to export single frames and then convert those with ImageMagick. Maple offers ssystem(„...“) which allows for command line usage.

The problem (may as well be a bug) occurs when I try to export images in a for loop with exportplot(...). If the path as well as previously exported images exist, it won't output an error but still not export the desired images. Exporting frames separately works just fine, as well as doing the very same operation in a separate for loop.

(see the first red comment and export section)

After using the workaround in a second for loop. I couldn't figure out how to import the images and then create an animation from them. The main obstacle is the fact that the imported pictures are put into plot-functions.

(see the second red comment)

 

restart;

with(plottools):

f1 := s -> sin(2*s):

max_frame := 10: # = number of steps

for k from 0 to max_frame do
    pic[k] := plot(f1(x), x=-Pi*(1-k/max_frame)..Pi*(1-k/max_frame),
                    filled=true, #color = ["Orange"],
                    color = ColorTools:-Color([0,
                                              floor(128*k/max_frame),
                                              floor(255*k/max_frame)
                                              ]),
                    view=[-Pi*(1-k/max_frame)..Pi*(1-k/max_frame), -1..1]
                    ):
end do:

path := FileTools:-TemporaryDirectory();
path_list := ssystem("pwd");
path := path_list[2];
ssystem("mkdir ./pics"); # creates a subfolder
path := FileTools:-JoinPath([path, "pics"]); # need to change path to subfolder

plotsetup(window, plotoptions="width=480, height=600");
for k from 0 to max_frame do
    file[k] := FileTools:-JoinPath([path,
                                     MapleTA:-Builtin:-strcat("frame_",
                                                              convert(k, string),
                                                              ".jpg")
                                    ]);
    # exportplot(file[k], pic[k]); # does not work
end do:

exportplot(file[0], pic[0]); # works

# =====================================================================================
# export
# =====================================================================================
for k from 0 to max_frame do
  exportplot(file[k], pic[k]);
od; # also works

# =====================================================================================
# import
# =====================================================================================
for k from 0 to max_frame do
    reimported_pic[k] := importplot(file[k]); # this might take a while (depending on the amount of frames)
end do: # import works but [Length of output exceeds limit of 1000000]

whattype(reimported_pic[0]); #seems to create a plot function
show := convert(reimported_pic,list):
#Error, while processing result #There is no help page available for this error

show[1]; # works

# =====================================================================================
# create an animated gif at least
# =====================================================================================
delay_time := ceil(evalf(100/max_frame));
command_for_gif := MapleTA:-Builtin:-strcat("convert -delay ",
                                            convert(delay_time, string),
                                            " -loop 0 ", # -reverse ",
                                            FileTools:-JoinPath([path, "frame_*.jpg "]),
                                            FileTools:-JoinPath([path, "animation.gif"])
                                            );
ssystem(command_for_gif);

 

 

Download bug_report_maybe.mw

 

I would be grateful for any suggestions. Moreover I have run accross

?DocumentTools:-Components:-VideoPlayer

which I could not figure out how to use by the help pages (I tried to create an avi and import that). If someone has informations on that, please share!

how to convert (a+b)^3 to a list [a+b, a+b, a+b]?

for example

(a+b)^2 to [a+b, a+b]

Is there a way to automatically convert and paste my clipboard contents as 2D math?

 

 

 

 

Can we calculate the following equations in Maple?

Substituting equations (21) and (22) into (17), and then obtain equation (23). How to do that? I have done this, but the results are complex and large. They are not in a sum form, but in an expansion form. The reference and the maple file are attached.

Hope for your help.

Best wishes,

Kang

Dynamic_buckling_of_thin_isotropic_plates_subjected_to_in-plane_impact.pdf

gg.mw

hi...how i can convert 3 couple equations to 1 equation with Placement each other?

thanks...

 

3-1.mw

pd1 := A1*(diff(U(x, theta), x, x, x, x))+A2*(diff(U(x, theta), x, x))+A3*(diff(U(x, theta), x, x, theta, theta))+A4*(diff(V(x, theta), x, x, x, theta))+A5*(diff(V(x, theta), x, theta))+A6*(diff(V(x, theta), x, theta, theta, theta))+A7*(diff(W(x, theta), x, x, x))+A8*(diff(W(x, theta), x))+A9*(diff(W(x, theta), x, theta, theta))+A10*(diff(U(x, theta), theta, theta))+A11*(diff(U(x, theta), theta, theta, theta, theta))-A12*omega^2*U(x, theta)

A1*(diff(diff(diff(diff(U(x, theta), x), x), x), x))+A2*(diff(diff(U(x, theta), x), x))+A3*(diff(diff(diff(diff(U(x, theta), theta), theta), x), x))+A4*(diff(diff(diff(diff(V(x, theta), theta), x), x), x))+A5*(diff(diff(V(x, theta), theta), x))+A6*(diff(diff(diff(diff(V(x, theta), theta), theta), theta), x))+A7*(diff(diff(diff(W(x, theta), x), x), x))+A8*(diff(W(x, theta), x))+A9*(diff(diff(diff(W(x, theta), theta), theta), x))+A10*(diff(diff(U(x, theta), theta), theta))+A11*(diff(diff(diff(diff(U(x, theta), theta), theta), theta), theta))-A12*omega^2*U(x, theta)

(1)

pd2 := B1*(diff(V(x, theta), x, x, x, x))+B2*(diff(V(x, theta), x, x))+B3*(diff(V(x, theta), theta, theta, theta, theta))+B4*(diff(V(x, theta), theta, theta))+B5*(diff(V(x, theta), x, x, theta, theta))+B6*(diff(U(x, theta), x, x, x, theta))+B7*(diff(U(x, theta), x, theta, theta, theta))+B8*(diff(U(x, theta), x, theta))+B9*(diff(W(x, theta), x, x, theta))+B10*(diff(W(x, theta), theta, theta, theta))+B11*(diff(W(x, theta), theta))-B12*omega^2*V(x, theta)

B1*(diff(diff(diff(diff(V(x, theta), x), x), x), x))+B2*(diff(diff(V(x, theta), x), x))+B3*(diff(diff(diff(diff(V(x, theta), theta), theta), theta), theta))+B4*(diff(diff(V(x, theta), theta), theta))+B5*(diff(diff(diff(diff(V(x, theta), theta), theta), x), x))+B6*(diff(diff(diff(diff(U(x, theta), theta), x), x), x))+B7*(diff(diff(diff(diff(U(x, theta), theta), theta), theta), x))+B8*(diff(diff(U(x, theta), theta), x))+B9*(diff(diff(diff(W(x, theta), theta), x), x))+B10*(diff(diff(diff(W(x, theta), theta), theta), theta))+B11*(diff(W(x, theta), theta))-B12*omega^2*V(x, theta)

(2)

pd3 := C1*(diff(W(x, theta), x, x, x, x, x, x))+C2*(diff(W(x, theta), x, x, x, x))+C3*(diff(W(x, theta), x, x, x, x, theta, theta))+C4*(diff(W(x, theta), x, x))+C5*(diff(W(x, theta), x, x, theta, theta))+C6*(diff(W(x, theta), x, x, theta, theta, theta, theta))+C7*(diff(U(x, theta), x, x, x))+C8*(diff(U(x, theta), x))+C9*(diff(U(x, theta), x, theta, theta))+C10*(diff(V(x, theta), x, x, theta))+C11*(diff(V(x, theta), theta))+C12*(diff(V(x, theta), theta, theta, theta))+C13*W(x, theta)+C14*(diff(W(x, theta), theta, theta))+C15*(diff(W(x, theta), theta, theta, theta, theta))+C16*(diff(W(x, theta), theta, theta, theta, theta, theta, theta))-C19*omega^2*W(x, theta)-C18*omega^2*(diff(W(x, theta), theta, theta))-C17*omega^2*(diff(W(x, theta), x, x))

C1*(diff(diff(diff(diff(diff(diff(W(x, theta), x), x), x), x), x), x))+C2*(diff(diff(diff(diff(W(x, theta), x), x), x), x))+C3*(diff(diff(diff(diff(diff(diff(W(x, theta), theta), theta), x), x), x), x))+C4*(diff(diff(W(x, theta), x), x))+C5*(diff(diff(diff(diff(W(x, theta), theta), theta), x), x))+C6*(diff(diff(diff(diff(diff(diff(W(x, theta), theta), theta), theta), theta), x), x))+C7*(diff(diff(diff(U(x, theta), x), x), x))+C8*(diff(U(x, theta), x))+C9*(diff(diff(diff(U(x, theta), theta), theta), x))+C10*(diff(diff(diff(V(x, theta), theta), x), x))+C11*(diff(V(x, theta), theta))+C12*(diff(diff(diff(V(x, theta), theta), theta), theta))+C13*W(x, theta)+C14*(diff(diff(W(x, theta), theta), theta))+C15*(diff(diff(diff(diff(W(x, theta), theta), theta), theta), theta))+C16*(diff(diff(diff(diff(diff(diff(W(x, theta), theta), theta), theta), theta), theta), theta))-C19*omega^2*W(x, theta)-C18*omega^2*(diff(diff(W(x, theta), theta), theta))-C17*omega^2*(diff(diff(W(x, theta), x), x))

(3)

``


Download 3-1.mw

hi

i have a problem with convert mathematica code in to maple one

i attached maple file .some line have error.please help me for remove error

thanks

fdm.mw

fdm.pdf

Dear Community,

Is there an easy way to convert elapsed days since January 1 1900 to date, i.e. to year, month, day in Maple? E.g. 23021 days should convert to 1963.01.10. Also what is the opposite, i.e. from date to elapsed days?

tx in advance,

best regards

Andras

hi.how convert root of to explicit form.

w is a imaginary..

thanks

123.mw

restart; w := (1/2)*(2*d-5+I*sqrt(4*d-9))/(d-2)

(1/2)*(2*d-5+I*(4*d-9)^(1/2))/(d-2)

(1)

with(LinearAlgebra):

{Q1 = RootOf((2*I)*(4*d-9)^(1/2)*_Z*d-((2*d-5+I*(4*d-9)^(1/2))/(d-2).(d*(I*(4*d-9)^(1/2)+1)*_Z/((d-2)*b)))*b*d+2*((2*d-5+I*(4*d-9)^(1/2))/(d-2).(d*(I*(4*d-9)^(1/2)+1)*_Z/((d-2)*b)))*b-2*d*_Z), Q2 = -(1/2)*d*(I*(4*d-9)^(1/2)+1)*RootOf((2*I)*(4*d-9)^(1/2)*_Z*d-((2*d-5+I*(4*d-9)^(1/2))/(d-2).(d*(I*(4*d-9)^(1/2)+1)*_Z/((d-2)*b)))*b*d+2*((2*d-5+I*(4*d-9)^(1/2))/(d-2).(d*(I*(4*d-9)^(1/2)+1)*_Z/((d-2)*b)))*b-2*d*_Z)/((d-2)*b)}

(2)

``

 

Download 123.mw

hi

if possible to convert matlab file in to maple fie program??convert_to_maple_program.txt

thanks

 

Hi guys,

 

I would like to convert a piecewise defined function of two variables into an if structure
Example :

F := (x,y) -> piecewise(x < 0, piecewise(y < 0, 0, 1), piecewise(y < 0, 1, 0));

What I expect is something like (the indentation is just for fun)
if x < 0 then
   if y < 0 then 0 else 1 end if;
else 
   if y < 0 then 1 else 0 end if;
 end if


I tried the following :

convert(F(x,y), `if`)  # but it only converts the "outer x condition" and keeps the "inner y conditions" unchanged

And next this :

map(u -> convert(u, `if`), F(x,y)):   # fails to give m
# and
map(u -> convert(u(x,y), `if`), F(x,y)): 
# ...

without success.

Can anoybody help me please.
I am also interested in an explanation of the reasons why the previous command do not work.

Thanks all

I resolve the surface flat grinding of a metal pieces in Mathematica, but I would like convert this program in Maple syntaxis. 

Thanks in advance!

For example, I havd matrix m:=[0 1 0 1 0 1 0], I want to convert it back to m:=[0,1,0,1,0,1,0]. Can someone help to solve? Thank you.

A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

The Question: Transforming functions to names

Bendesarts wanted to know how to make programmatic changes to characters in a list. He wrote:

I have this list :

T:=[alpha(t),beta(t)]

I would like to create this list automatically:

Tmod:=[alpha_,beta_]

In other words, how can I remove the 3 characters "(t)" and replace it by "_"

Do you have ideas to do so ?

Thanks a lot for your help

Joe Riel provided a complete answer that had three different approaches. He wrote:

Map, over the list, a procedure that extracts the name of the function and catenates an underscore to it. The function name is extracted via the op procedure, e.g. op(0,f(a,b,c)) evaluates to f. Thus 

map(f->cat(op(0,f),_),T);

Note that this fails if the name of a function is indexed, e.g. f[2](a). No error is generated but the catenation doesn't evaluate to a symbol. Presumably that isn't an issue here.  One way to handle that case is to first convert the indexed name to a symbol, then catenate the underscore.  So a more robust version is

map(f->cat(convert(op(0,f),'symbol'),_),T);

However, if you are actually dealing with indexed names you might want a different result. Another way to do the conversion, and combine it with the catenation, is to use nprintf, which generates a name (symbol). Thus

map(f -> nprintf("%a_", op(0,f)),T);

 

Let’s discuss each approach by understanding the definitions and functionalities of the commands used. 

The map command, map(fcn, expr, arg1, ..., argN) applies a procedure or name, fcn, to the operands or elements of an expression, expr. The result of a call to map is a copy of expr with the ith operand of expr replaced by the result of applying fcn to the ith operand.  This concept is easier to grasp by looking at a few examples related to the usage of map in this question.

Example 1.  map(x-> x2,x+y)         returns     x2+y2                    

Example 2. map(a -> a-b, sin(x))    returns     sin(x-b)

 

The cat function, cat(a,b,c,…), is commonly used to concatenate (or join) string and names together. This function’s parameters: a,b,c…, can be any expressions.

Example 1. cat(a,2)                      returns     a2

Example 2.  cat(“a”,3,sin(x))          returns    “a3sin(x)”

 

The op function, op(i..j,e), extracts operands from an expression. The parameters i and j are the integers indicating positions of the operands and e is the expression. For functions, as in this example, op(0,e) is the name of the function.

Example 1.  op(0,alpha(t))            returns   the symbol alpha

Example 2.  op(0, sin(x))              returns    sin

 

Now analyzing Joe Riel's code will be easier.

  1. map(f->cat(op(0,f),_),T);

In this approach Joe is extracting the name of the functions, alpha and beta, and then concatenating it to the underscore symbol. Then using the mapping function he applies the previous procedure to the list T.

  1. map(f->cat(convert(op(0,f),'symbol'),_),T);

This approach is a lot similar to the previous one, but he added the convert function in case the function inside of map was indexed. Convert(expr, form, arg3,..), is used to change an expression from one form to another. In this example op(0,f) has been changed from type name to type symbol.

  1. map(f -> nprintf("%a_", op(0,f)),T);

Again this is a similar approach but it uses nprintf. This command, nprintf(fmt,x1,..xn), is based on a C standard library command of the same name. It uses the format specifications in the fmt string to format and writes the expression into a Maple symbol, which is returned. In this example the format specified is the algebraic format “%a”.

 

This blog was written by Maplesoft’s intern Pia under the supervision of Dr. Robert Lopez. We both hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let us know. 

Hi everyone,

 

I converted a code from Maple 18 to Fortran 77 but the code is badly cut, for instance:

cg = -(F * h * p ** 2 - F * h * q ** 2 + 0.2D1 * F * k * p * q + c
     #os(F) * sqrt(-e ** 2 + 0.1D1) * p ** 2 - cos(F) * sqrt(-e ** 2 + 0.

Is there an option which can force the line cut to be done in an optimized way?

Thank you very much for your help!

>nombor1:=[4,6,2];

nombor1:=[4,6,2]

 

Hi, anyone know hot i need to continue my command to get 462 from [4,6,2]?

Thank you~=]]

1 2 3 4 5 6 7 Last Page 1 of 42