cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Problem plotting function with range variable

ChrisRae
1-Visitor

Problem plotting function with range variable

I've been using R14 for a while and recently tried switching to Prime to see if it would be a useful upgrade, but I've failed miserably at reproducing some very simple work from R14 (I didn't want to uninstall R14 to put R15 on to do the conversion so I thought I'd try something from scratch).

I would like to plot the result of a simple function across a range, I've declared the function and verified it works but I can't plot it using a range variable for one of the arguments?

It gives me the error "There are too many range variables"...what am I doing wrong?

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:ChrisRae)

Chris Rae wrote:

I've been using R14 for a while and recently tried switching to Prime to see if it would be a useful upgrade,

Not yet, in my opinion.

The error is a funny one and unfortunately not so seldom with Prime.

The error message is nonsense and absolutely not helpful, though.

I recreated the graph in your sheet and it worked immediatly. Finding the error took a bit longer.

Its the theta as argument in the function T.out in the plot. It is formatted (style) as "variable" (as it is above in the declaration above) and if you change it to "none" it works. The other parameters can stay styled as "variable".

It seems to me to be a bug. If I delete the whole function call and retype it, all parameters get style "none" for reasons only PTC will know of, if any.

P.S.: If you want a sheet created in real Mathcad be converted to Prime format, post it here and I am sure, someone will be willing to do the conversion for you.

View solution in original post

18 REPLIES 18
Werner_E
25-Diamond I
(To:ChrisRae)

Chris Rae wrote:

I've been using R14 for a while and recently tried switching to Prime to see if it would be a useful upgrade,

Not yet, in my opinion.

The error is a funny one and unfortunately not so seldom with Prime.

The error message is nonsense and absolutely not helpful, though.

I recreated the graph in your sheet and it worked immediatly. Finding the error took a bit longer.

Its the theta as argument in the function T.out in the plot. It is formatted (style) as "variable" (as it is above in the declaration above) and if you change it to "none" it works. The other parameters can stay styled as "variable".

It seems to me to be a bug. If I delete the whole function call and retype it, all parameters get style "none" for reasons only PTC will know of, if any.

P.S.: If you want a sheet created in real Mathcad be converted to Prime format, post it here and I am sure, someone will be willing to do the conversion for you.

Werner_E
25-Diamond I
(To:Werner_E)

Addendum:

A better and more logical way to correct it, is to assign the variable theta on the abscissa the style "variable"!

Excellent, thanks for the responses, I can see the issue now, although I'm not sure how it occurred (or why the error message was so uselessly cryptic!). As you suggested I'm not sure this new version is ready for me to make the switch.

Hi Werner,

Thanks for the great post here! I am also having the same issue. I tried to apply your suggestion, but in my case, it does not seem to work. I have attached my Mathcad Prime 2.0 file here.

Do you know why I keep getting the message "There are too many range variables?"

Thanks!

Werner_E
25-Diamond I
(To:ptc-4930211)

Your x[i,n results in a lot of invalid matrxi indices - dont know why Mathcad is not throwing an error in the evaluation to the right. r is a 301-element vector as so you should have a vector (not a 2-dimensional matrix) of same dimension on the ordinate. For instance a specific column of matrix x.

chaos1.png

Thanks, Werner. But in the plot you sent me, it is just showing one of the values. I would like to plot all of them. It works in Mathcad 14, but I cannot make it to work in Mathcad Prime.

The plot I am trying to make is the bifurcation diagram. Take a look at the first figure on the Wikipedia website at: http://en.wikipedia.org/wiki/Bifurcation_diagram

Werner_E
25-Diamond I
(To:ptc-4930211)

I think you will find some solutions here in the forum, too, if you search for Feigenbaum, bifurcation, etc.

Prime still is a work in progress, Mathcad 14 being far superior. Why would you use Prime voluntarily?

Anyway, in Prime you can simply plot the matrix x over the vector r. You have to change the diagram type to "waterfall plot" to make it work. Also it seems that Prime has a bad upper limit for the number of points it is willing to plot so you will have reduce something in your matrix. Prime is very limited. As a quick hack I have set N to 90 to make it work. I found no way to tell Prime not to connect the points..

You may use submatrix to eliminate the first columns of the matrix x, maybe that helps in using only the higher iterations steps.

chaos2.png

Thank you so much, Werner! This was very helpful! I agree entirely with you that Prime is limited compared to Mathcad 14 when it comes to this type of plots.

Thanks!

Werner_E
25-Diamond I
(To:ptc-4930211)

This is better now, but in no way real Mathcad

If we chose to plot more than 5000 (yes, 5k, not 50k) points, Prime will connect them - crazy!

chaos3.png

Werner, this looks so much better! Thank you so much!

Huy_Nguyen
4-Participant
(To:Werner_E)

Hi. I am trying to setting ranges of variables in plot in ptc v.7.0. But it is really difficult to me. Can you give me some advices? Thank you so much.

Huy_Nguyen_0-1664172956737.png

Huy_Nguyen_1-1664172972940.png

 

 

Werner_E
25-Diamond I
(To:Huy_Nguyen)

See here: https://community.ptc.com/t5/Mathcad/How-to-set-ranges-of-variables-in-a-plot-in-Mathcad-prime/td-p/826088/jump-to/first-unread-message

It is always better in such cases to open a separate new thread with your question 😉

KAndersen
4-Participant
(To:Werner_E)

Hello all,
I think I am in the correct thread. I am having a similar problem. Essentially, I am trying to make a Bode plot on the last page of this MathCAD Prime 8 file.

Thank you in advance for any help with this issue.
Kind regards,
Kyle

Cornel
19-Tanzanite
(To:KAndersen)

@Werner_E 

Hm...Werner, one of the problems here is related to what I posted already previous days about the inverse of a matrix and calculating the determinant:

CornelBejan_0-1674676433437.png

CornelBejan_1-1674676439795.png

CornelBejan_2-1674676453857.png

CornelBejan_3-1674676460688.png

CornelBejan_4-1674676476565.png

CornelBejan_5-1674676492971.pngIt seems hard to believe that the above result is correct..
Maybe Werner can better explain the problems related to calculating the inverse of a matrix, and calculating the determinant..problems you encounter at least in Mathcad (Prime)...

Another problem that I see:

CornelBejan_6-1674676802315.png

CornelBejan_7-1674676820602.png

 

 

Werner_E
25-Diamond I
(To:KAndersen)


@KAndersen wrote:

Hello all,
I think I am in the correct thread.


I tend to disagree! This nearly five year old thread is not YOUR thread and this thread already was so often hijacked by people having various problems with plotting for different reasons. So its rather long and dealing with various different, unrelated problems which strongly diminishes the willingness to deal with it in more detail. Furthermore this thread is already closed / marked as "answered". So follow up posting sure don't get the same attention as a new opened thread will get.

So I can only suggest that you open a new thread with your question. You don't need to zip the worksheet to attach it.

I would also suggest that you clearly describe what kind of plot you would like to see because the way you had setup your plot sure can't result in a bode plot. The error message states that Prime (on contrary to real Mathcad) does not allow two arguments being ranges. Furthermore you just have nine values for "n" and four values for "exp" - so at the best your plot would consist of just 36 separate points!

 

BTW, I don't think that your problem is in any way related to the one of @Cornel which had to do with symbolic evaluations in this still open thread https://community.ptc.com/t5/Mathcad/Determinat-of-a-Matrix-Mathcad-Prime-8-Strange-Result/m-p/851428/highlight/true#M204835

LucMeekes
23-Emerald III
(To:KAndersen)

See attached file.

 

Success!
Luc

Werner_E
25-Diamond I
(To:LucMeekes)

Using the quickplot feature (=not defining the frequency via "logspace" or "Decade", leaving "fr" undefined and setting the plot ranges in the plot itself by editing the first an last value at the x-axis) seems to provide a nicer output.

Werner_E_1-1674682358015.png

 

EDIT: Of course using your method you can get an equally smooth plot if you use more than just 10 points per decade. The benefit of using "logspace" or your "Decade" is sure having a better control over the output.

 

KAndersen
4-Participant
(To:Werner_E)

Thank you everyone!
@Werner_E @LucMeekes @Cornel

I am very grateful for the help. I used your suggestions and the plot coming along nicely.

I apologize for posting in a closed thread. It won't happen again.

 

Kind regards,
Kyle

Announcements

Top Tags