cancel
Showing results for 
Search instead for 
Did you mean: 
Security Alert Log4j Security Vulnerability. Click here to know more.
cancel
Showing results for 
Search instead for 
Did you mean: 

sorting data

payman
13-Aquamarine

sorting data

Hello,

Could anyone help me to sort the output of my attached program so I can plot I(k0) when x-axis is "d" and y-axis is "theta" ?

thank you very much in advance

Payman

1 ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:payman)

I assume you want a 3D plot with d on the x-axis, theta on the y-axis, and I(k0) on the z-axis:

As others have noted, move stuff out of the inner loop that does not need to be there. You also don't need to create large vectors or matrices of intermediate results that you do not return from the program.

View solution in original post

10 REPLIES 10
-MFra-
21-Topaz I
(To:payman)

Hi PR,

I tried to interpret your request, I hope I have guessed what you want.

Bye Bye

FM

optics.jpg

payman
13-Aquamarine
(To:-MFra-)

Thank you very much F.M.

Could you please briefly explain about the last graph? How did you generate it?

Thank you.

StuartBruff
23-Emerald I
(To:payman)

Another approach is to use a 3D plot.

Stuart

PS: As FM has indicated, you can improve the efficiency of your programs by moving expressions out of loops where the expressions don't depend on the loop variable.   If you don't intend to vary d, you could just replace it by j.

RichardJ
19-Tanzanite
(To:payman)

I assume you want a 3D plot with d on the x-axis, theta on the y-axis, and I(k0) on the z-axis:

As others have noted, move stuff out of the inner loop that does not need to be there. You also don't need to create large vectors or matrices of intermediate results that you do not return from the program.

View solution in original post

Werner_E
24-Ruby IV
(To:RichardJ)

Additional remark: In case you'd like to see theta in degrees rather than radians, you may change the last line in the program to read "Theta/deg" instead of "Theta".

I am a little bit confused as of the calculation of phi. Is it really an angle in radiant?

WE

Mmm... I get this other plot.

Alvaro.

plot.jpg

When you call "CreateMesh" theta runs from 0 to 89, but those values are interpreted as radiants in your function, not as degrees as it should be. Try to let theta run from 0 to pi/2 and you should come closer to the plots we have seen in the posts before.

Furthermore because of the limit in the number ov intervals in "Createmesh" you won't get the resolution of Richards plot in d-direction.

I am still not sure if phi is really meant to be what is calculated here.

Werner

Jejeje. Yes, you're right. i'm confuse rad with deg, as you prevent in your previous post.

Thanks, best regards.

Alvaro.

payman
13-Aquamarine
(To:payman)

I really appreciate all of you for your valuable suggestions. For the last step, I need to export the data to Sigmaplot. I was not able to do this step from the output of the suggested method, so I modified the program. The new data set generrates different contour plot in Mathcad , but when I transfer them to Sigmaplot, the same contour plot can be obtained as you obtained here. Am I doing a mistake here?


Thank you.

Werner_E
24-Ruby IV
(To:payman)

In your last attempt you just create 3 vectors with the x-, y- and z-values of a bunch of points. Mathcad can't create a surface if it is just given a number of points - it does not know how to connect them - it would need a mesh.

But Mathcad can plot each point. Just change from contour plot to "scatter plot" and format the point size and color. I am not sure why, but the plot looks much better if I set a samll amount (1% is all it needs) of transparency.

Here is what I got:

Regards

Werner

Announcements
Check out the latest
Mathcad Tip
"PTC Mathcad 15 / Prime 1-6 Update."