Items tagged with loop loop Tagged Items Feed

Hallo. I'd like to make a loop for two variables. Let say:

for i from 1..10, j from 1..10

How to do it?

Thanks.

for a to z1/T1 do ics[a*T1] := [g0(0, a*T1) = r, g0(1, a*T1) = s] end, this loop runs correctly for T1:=1, but gives the too many levels of recursion error for T1<1. In this loop i am inserting equations g0 in a list ics.

Hi every body:

I have a problem with below function (f(x)), I will calculate values this function with for loop so that values are closer together. for example I will earn 10 or 20 data for this function so that they differences have to be fixed.my means is that I have 10 data like, 50,65,85,90,100,... no 50,100,170,... . that isn't important for me the data increase with constant value but my final data must be closer together. (the maximum number of my data to be taken is 50). 

function is:

f:=(x)->(310*(z+0.5)^0.2)+70

z=[-0.5,0.5]

 

with regards...

Mehran.

I have a set of equations icsi and a set of variables v. How do i assign each solution to the variable before solving the next equation?

I tried- for i from 1 to 3 do solvedi := solve(icsi, vi);assign(solvedi); end. This didn't work for me.

Here is a simple example to explain my problem:

I would like to have a break after the first graph and with return

the loop shoul continue to the next and so on.

Thank you for your help!

 

Test:=proc()

    plot(x^j,x=-2..2):

end proc:

for j from 1 to 3 do

   Test()

end do;

Dear  i want to plot the graphs for different values of R[2,5,6.5]   here is the codes: Either ido loop or array i have to use or other procedure 

The graph display should be at R=2, one graph, R=5 another and R=6.5 

onemore graph

 

restart:
with(DEtools):
eta:=1+k*x+epsilon*sin(2*Pi*x):
A1(x):=-exp(-alpha*x)*J^2*R/(2*eta^3+6*xi*J^2*eta^2):

psi0:=A1(x)*y^3:
psi:=delta*psi0:
V:=-diff(psi,x):
delta:=0.1:
epsilon:=0.01:
alpha:=1:
xi:=0.001:
k:=0.1:
As:= [0, 2, 4]:
x:=0.2
plot([seq]([eval(V, J= A), y, y= 0..eval(eta, J= A)], A= As),title=" velocity at R=2.0 ",labels= ["v", "y"],color= [green, red, blue], linestyle= [solid, dash, dot],legend= [seq](J = A, A= As), axes=boxed);

 

 

 

 

 

 

Hello

I am trying to do a do loop

X[1] := Statistics:-Sample(Binomial(200, .5), 1);

for i to 10 do X[i+1] := Statistics:-Sample(Binomial(200-X[i], .5), 1) end do;

And it shows error like this

Error, (in rtable/Sum) invalid arguments.

Did I do something wrong in my code?

Dear,

I am stuck in this task and wonder if someone could help me with this. I have a big code and, quite generally, receive as a result, say, three quantities, A, B, and C. My aim is create three other lists, list_A, list_B, and, list_C, in a way that each iteration will add to them the respective A[i], B[i], C[i]. My almost complete ignorance with Maple is turning this task a hell, despite in other languages I could do that with relativity ease.

Of course, I thought to put the entire code in a 'for-loop' but as far as I see this is complicated in Maple syntax.

Thank you very much for any kind of help, hint, material for reading, etc.

My best regards,

Hi,

I'm, trying to write a nested loop in maple, but I keep getting the Unterminated Loop error. I'm sure the solution is quite simple, but I haven't been able to find it. Any suggestions would be much appreciated. The loop looks like this:

 

i:=0:
di:=25:
n:=1:  

while (n<=nLimit) do
sol1:=fsolve(eq1, y=i..i+di)
     if type(sol1, numeric) = true then
     lambda(n) :=sol1
     i:=i+di
     n:=n+1
     else  i:=i+di
     end if:
end do:

Hello,

I have a question. I have to compare the times and steps taken by an algorithmus (which contents a loop).

So for time there is the time()-function, right? And is there any similar function for the steps taken?

So far i use a variable increasing by 1 each time, but i think there is an more elegant way to do it, which I just don't know.. :D

 

Thanks for any help!

 

Hello

I have some problem with " For loop". If i add more then one expression the, i recieve an error. Could you please help me to solve it? I have attached my file. Thank you.


restart 

with(ImageTools):NULL

with(FileTools):NULLNULL

Input Section

 

``

filelocation := "C:\\Users\\Mohammad\\Desktop\\ExerciseII\\1.jpg":

k := 3:``

 

zimage := Read(filelocation):

 

zwidth := Width(zimage):``

kernell := VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1):NULLNULL

kerneld := `~`[`*`](Array(1 .. kernell, 1 .. kernell, 1), 1/kernell^2):

imheight := Height(zimage):NULL

imwidth := Width(zimage):````

Width(zimage, lower):

Width(zimage, upper):

View(zimage):NULL

new1zpic := Convolution(zimage, kerneld):

View(new1zpic)NULL``

aa := zimage(1 .. (), 1 .. (), 1):

bb := zimage(1 .. (), 1 .. (), 2):

cc := zimage(1 .. (), 1 .. (), 3):NULL

subimage := Matrix(VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1), VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1), 0):

newaa := aa:

"for i from k+1 to (RowDimension(aa)-k-1) do     for j from k+1 to (ColumnDimension(aa)-k-1) do     subimage:=aa(i-k..i+k,j-k..j+k).~kerneld     newaa(i,j):=add(add(subimage(m,n),m=1..(2 .k+1),n=1..(2*k+1))) end do; end do;"

Error, unterminated loop

"for i from k+1 to (RowDimension(aa)-k-1) do     for j from k+1 to (ColumnDimension(aa)-k-1) do  subimage:=aa(i-k..i+k,j-k..j+k).~kerneld    newaa(i,j):=add(add(subimage(m,n),m=1..(2 .k+1),n=1..(2*k+1))) end do; end do;"

 

 

``


Download pak2.mw

Heyho,

I'm pretty new to Maple (started Monday). And I don't know how to solve (or even why it exists) the following error:

S3() generates two integers, one converted from a random 568-Bit-number "e" and one converted from a random 160-bit number "kp1", satisfying gcd(e,kp1)=1.
That works pretty fine so far.

 

Now I need two specific numbers, x and y defined by:

 

And I use the proc S4 to get them:

 

Sometimes, the error occurs "Error, (in S4) the modular inverse does not exist", and I dont get why,... I tried to fix it, with the "while"-loop, but it didnt work out yet.

Someone knows how to solve this problem?
Thanks!

 

Hello

1)I need some guides to solve my problem. I have attached my file. Could you please help me to understand what's wrong in my code?

2) Is there any option to pause "Loops" and watching results, something like break point.

THank you.

 

 

restart

 

with(ImageTools):``

with(FileTools):````

Input Section

 

NULL

filelocation := "C:\\Users\\Mohammad\\Desktop\\1.jpg":

k := 1:NULL

 

zimage := Read(filelocation):

zwidth := Width(zimage):NULL

kernel__length := VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1):````

kernel__data := `~`[`*`](Matrix(1 .. kernel__length, 1 .. kernel__length, 1), 1/kernel__length^2):

imheight := Height(zimage):``

imwidth := Width(zimage):NULLNULL

Width(zimage, lower):

Width(zimage, upper):

View(zimage):``

new1zpic := Convolution(zimage, kernel__data):

View(new1zpic)``NULL

new2zpic := zimage:

dummy := 0:

"for i from (k+1)  to (Width(zimage,upper)-k) do     for j from (k+1)  to (Height(zimage,upper)-k) do           for m from 1 to kernel[length]  do               for n from 1 to kernel[length]  do                         dummy:=dummy+kernel[data] (m, n)*new2zpic(i+m-2, j+n-2)                                         end do;              end do;                      new2zpic(i,j):=dummy:                   dummy:=0:   end do; end do;"

Error, final value in for loop must be numeric or character

 

 

 

 

NULL

 

Download Exercise_II-1.0.mw

restart

 

with(ImageTools):``

with(FileTools):````

Input Section

 

NULL

filelocation := "C:\\Users\\Mohammad\\Desktop\\1.jpg":

k := 1:NULL

 

zimage := Read(filelocation):

zwidth := Width(zimage):NULL

kernel__length := VectorCalculus:-`+`(VectorCalculus:-`*`(2, k), 1):````

kernel__data := `~`[`*`](Matrix(1 .. kernel__length, 1 .. kernel__length, 1), 1/kernel__length^2):

imheight := Height(zimage):``

imwidth := Width(zimage):NULLNULL

Width(zimage, lower):

Width(zimage, upper):

View(zimage):``

new1zpic := Convolution(zimage, kernel__data):

View(new1zpic)``NULL

new2zpic := zimage:

dummy := 0:

"for i from (k+1)  to (Width(zimage,upper)-k) do     for j from (k+1)  to (Height(zimage,upper)-k) do           for m from 1 to kernel[length]  do               for n from 1 to kernel[length]  do                         dummy:=dummy+kernel[data] (m, n)*new2zpic(i+m-2, j+n-2)                                         end do;              end do;                      new2zpic(i,j):=dummy:                   dummy:=0:   end do; end do;"

Error, final value in for loop must be numeric or character

 

 

 

 

NULL

 

Download Exercise_II-1.0.mw

Hi all,

I have some "boolean variable" constraint equation like this:

a1*x1+a2*x2+...+an*xn>=b1*y1+b2*y2+...+bn*yn

where a1,a2,...,an and b1, b2, ..., bn are 1 or -1

These equations will be used in LPSolve or the other command to find a group of parameters which can fit them.

Now I used for-loop to deal with this kind of question, for example:

But there are more than 10 boolean variables in my case and It's very inefficient. On the other hand, using for-loop to determine the equation we solve in the command will lead to great confusion.

I think there should be some ways able to solve this kind of "boolean variables" question in Maple, such as, through assume command to define the type of "boolean variable".

But I have no idea how to do it.

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