Bendesarts

420 Reputation

10 Badges

11 years, 323 days

MaplePrimes Activity


These are replies submitted by Bendesarts

@Rouben Rostamian  

So do you use the document mode, don't you ?

In this case, can you have the same presentation as Code Edit region but not in the dedicated windows ?

@acer

I try to add all my understanding about this code by adding comments and printf.

I precise the points where i have difficulties with questions marks.

alec_modified_hermit_2.mw

Can you help me to add more comments on this code ?

Thanks a lot for your help.

@tomleslie 

Thanks a lot for your help.

This code was working except for the plots.

However, I have still a small blocking point. In fact, to use the interpolatinf curves as trajectory setpoints in MapleSim, i need to definie these curves as explicit functions y=f(x) and not parametric curves. 

In fact, in my study case, I have 3 vectors ti, xi, yi and I would like to build the curves x(t) et y(t) which are respectively the curves which interpolate the points M1(t1,x1), … ,Mn(tn,xn), and P1(t1,y1), … ,Pn(tn,yn),
For the moment, the code gives a result with parametric curves.

My chance is that the vector ti is regurlary space. In other words, ti+1 -  ti keeps constant. Thus, I believe that it is possible to transform the parametric curves to explicit functions in this case x=f(t) et y=f(t).

I try to adapt my code to obtain results as explicit functions. But, the result obtained is a bit strange, the curve seems to be sampled. 

Can you have a look to my code in order to see if you see the blocking point ? I remember that my objective is to obtain explicit functions.

Here my code:

CRsplinefunction2.mw

Thanks a lot for your help.

@Rouben Rostamian  

This exactly what I was looking for.

However, isn't it possible to have the same kind of indentation but with the classic presentation of a maple worksheet ?

@Bendesarts 

I manage it works.

The process was :

1) Use ExcelTools:-Import(Folder\file.xls) to export the data and store it as a matrix.

2) Create a Datatable for this new created matrix.

3) Use this matrix.

Now, it the link with the Excel sheet dispear, my worksheet continue to work since the data are stored in the worksheet !

 

@acer 

Very good indeed.

And have you a idea so that I can feed the DataTable directly with a code line ?

The idea is to make this process:

DataTable:=ExcelTools:-Import(Folder\file.xls)

Thank you for your help.

@Carl Love 

Thank you for your help.

Indeed, I would prefer an explicit symbolic function because I need in a second step to implement my maple code in MapleSim.

@tomleslie 

Hello,

For the moment, I have used all the codes for which you have help me.

For the plot, you are right i forgot to correct this, but my mistake is belore. I try to correct with this plot1 := plot({[Courbe,t=0..6.99]}): and Courbe should be a vector containing 2 polynomes : one for x(t) and one for y(t).

The point was that i wanted to a piecewise function for the definition of the polynomial curve. In this program, this strategy is used. I also supply the definition of the theory that I would like to implement.

There are still some few errors at the end of the program. But, if you look at it in more details, i'm sure you find it far more easy to understand. Namely, it is more clear haow a spline is built and how the polynomial curve is built from the splines.

I hope that you will understand why I send you these news elements (the elements of theory which describes the construction of the polynomial curve and this new code). I try to do my best with my current knowledge with Maple.

I will be very grateful if you can have a look in more details of this last code. I promise you that I will do a detailled sum up of the results obtained with the 2 codes. Having this code working will enable me to better explain what the link between the theory of polynomial curve and its implementation of Maple and next, to show the elements which were missing for me for more clarity in the first code.

I thank you in advance for your understanding.

 

@tomleslie 

Hello,

Thank you again for you very helpful advice.

Here the piecewise polynomial curve with Catmull-rom splines that I try to implement :

 

The polynomial curve with Catmull-splines is defined as a piecewise function with the Catmull-Rom splines. By construction (Catmull-rom splines), the different splines are continuous for the function and its derivative.

With the help of this web page
http://www.dgp.toronto.edu/~elf/2505/maple.html 

I almost obtain the code desired so as to match points with this kind of polynomiale curve.

I have still some problems at the end of my code but it should be slight mistakes.

May you have a look to see if you can see these mistakes ?

Here is my code :

CalculSplineMatmull-Rom_version_toronto_4bis.mw

Thanks a lot for your help.

@Carl Love 

Thank you carl for you very pedagogical remark. It's indeed very helpful for me.

@tomleslie 

Perfect ! Thanks a lot for your help.

I have indeed make a mistake on the definition of n which is defined as a function in the book and wasn't defined like this in my code.

I have corrected by using unapply function.

Now, i do obtain the same results than in the book.

I attach here the last version of my code:

CalculSplineMatmull-Rom.mw

However, there are some lines that I didn't understand which are :

pp:=n[0](t-i+1)*M[i-1]+n[1](t-i+1)*M[i]+n[2](t-i+1)*M[i+1]+n[3](t-i+1)*M[i+2]; 
return evalm(sum((1+signum(-t+i))*(1+signum(t-i+1))/4*pp,
i=1..Num-2
)
):


Normally, I guess these lines enable the definition of the curve with the Catmull-Rom splines. But, I didn't understand the operation of it namely the 2 following points :
- why it used the index (t-i+1) in the defintion of pp ?
- how the return function works? I have seen the help, but i didn't seen any examples which makes me difficult to understand for me.

Otherwise, the definition of the polynomial curve defined with Catmull-Rom splines which I would like to implement works normally like this :

You takes 4 points (M1M2M3M4). The polynomial curve obtained with the Catmull-Rom splines is a curve between the point M2 and M3 (match with M2 and M3.

Next, you takes 4 others points (M2M3M4M5). The polynomial curve obtained with the Catmull-Rom splines is a curve between the point M3 and M4 and so on.

Here a picture to illustrate how the Cadmull-Rom splines works:

I think that the use of the function "piecewise" should be adapted to the definition of this polynomial curve with Catmull-rom splines.

May you help me to implement this polynomial curve with a piecewise function in Maple ?

This way can be more easy to understand (because simpler) than the solution proposed in this book.

Thanks a lot for your help

 

@tomleslie 

Thanks a lot for your help.

You were right, I have forgotten that I have changed the name of the procedure.

I have taken all your remarks into account.

However, I didn't obtain yet the result obtained in the book which is :

 

Here you can find my code :

CalculSplineMatmull-Rom.mw

1) May you see if you have ideas why I didn't the curves expected ?

2) Otherwise, normally, the different polynoms that I need to define with piecewise function are :

For the moment, in the lines seem to be programmed like this in my code :

pp:=n[0](t-i+1)*M[i-1]+n[1](t-i+1)*M[i]+n[2](t-i+1)*M[i+1]+n[3](t-i+1)*M[i+2];
return evalm(sum((1+signum(-t+i))*(1+signum(t-i+1))/4*pp,
i=1..Num-2
)
):

I have difficulties to understand the code lines.

Do you have ideas so that I can understand the link with the polynoms that I have to define with Catmull-rom splines ?

Thank you for your help

I manage to select only the ZeroCrossing values with a positive derivative with the slight modification in italic and underlined.

Here my code:

ZerosFrontMontant:= proc(A::Matrix)
local Z:= table(),k;
for k to op([1,1], A)-1 do
if A[k,2]*A[k+1,2] <= 0 and A[k,2]<A[k+1,2] then
Z[k]:= (A[k,1]*A[k+1,2] - A[k+1,1]*A[k,2])/(A[k+1,2]-A[k,2])
end if
end do;
convert(Z, list)
end proc:
for i to 4
do
Pz[i]:=ZerosFrontMontant(Matrix([<tk>,<vvals[i]>]));
LignesVerticales[i]:=plot([seq([Pz[i][j],t,t=-0.05..0.2],j=1..nops(Pz[i]))],colour=orange,linestyle=3, thickness=2,view=[0..2,default]):
od:

Thank you for your help!

@Carl Love 

Great! Thank you for your help.

1) Why the 2Pi value is not found ?

2) You process is perfect. But, i notice that i still need some modifications in order to select only the zero crossings with a increasing value that is to say with a positive derivates. 

The point is that with a explicit parametric curve i could obtain easily the derivative and so select the desired zero crossings. Here, i have difficulties to reduce the zero-crossings to the zero-crossings with a positive derivative. May you help me to modify you procedure so as to obtain the zero-crossings which have a positive derivative?

thanks a lot for your help.

@tomleslie 

Hello,

in fact, i could obtain the plot of the vertical points.

But, I'm still blocked for the determination of the zero crossing values. In fact, for the moment, i could obtain them only for a explicit parametric curve with a Roots function or solve function.

But, i didn't find the zero crossing values for the non linear oscillator. Consequently, it will great if you can give me a last tip for this point. 

Thanks a lot for your help. You have learn me a lot of thing.

5 6 7 8 9 10 11 Last Page 7 of 17