Skip to main content
15-Moonstone
May 5, 2022
Solved

Plot problem

  • May 5, 2022
  • 2 replies
  • 3077 views

Hello!

 

There is something wrong with the plot of the function (look at the attached file).

When "x" is defined from 0 to 10 the plot looks correct. But when I define "x" from -10 to 10 plot looks like a straight line.

Where did I make a mistake during the plot?

 

Best regards,

Sergey

Best answer by DJNewman

You should define x as -10, -9 ... 10 instead of -10, 1...10.

Edit: Alternatively just write it as -10 ... 10 if you want your step size to be 1.

 

https://support.ptc.com/help/mathcad/r8.0/en/index.html#page/PTC_Mathcad_Help/range_operators.html

2 replies

DJNewman
DJNewman18-OpalAnswer
18-Opal
May 5, 2022

You should define x as -10, -9 ... 10 instead of -10, 1...10.

Edit: Alternatively just write it as -10 ... 10 if you want your step size to be 1.

 

https://support.ptc.com/help/mathcad/r8.0/en/index.html#page/PTC_Mathcad_Help/range_operators.html

PTC Marketer for Creo and Mathcad. I run their YouTube channels, some Creo campaigns, and all Mathcad campaigns and communications.
23-Emerald V
May 5, 2022

@Sergey wrote:

Hello!

 

There is something wrong with the plot of the function (look at the attached file).

When "x" is defined from 0 to 10 the plot looks correct. But when I define "x" from -10 to 10 plot looks like a straight line.

Where did I make a mistake during the plot?

 

Best regards,

Sergey


Hi Sergey.

 

Your problem arises because you have (I think) used your intended step size in the range variable x's definition.

 

A range is defined as first_value,next_value..final_value. Mathcad uses the first and next values to calculate the step size.  You have x:=-10,1,10.  Consequently, Mathcad thinks you want x taking the values 10 and 1 (the next value after 1 would be 12, but the max range value you've give is 10).  What you want is x:= -10,-9..10.

 

2022 05 05 h.png

 

Revised Mathcad Prime 8 worksheet attached.

 

Stuart

Sergey15-MoonstoneAuthor
15-Moonstone
May 5, 2022

Hello Stuart.

 

It seems that you are right. I simply misunderstood how to define the step and the range.

Now it is clear.

 

Thanks a lot.

 

Best,

Sergey

23-Emerald V
May 5, 2022

No worries, Sergey.   It's a common Mathcad error, particularly when people have some familiarity with languages that use steps instead of the next value in the sequence.

 

Sometimes, it's useful to have the choice, so I have a library of sequence generation functions in my default worksheet.

 

2022 05 05 i.png

 

2022 05 05 j.png

 

 

You could even define a function - range, say - that generates a range using the first, next .. final specification:

 

2022 05 05 k.png

 

Mathcad Prime 7 worksheet attached - it should work in Mathcad Express 7 and Mathcad Prime/Express 8, as well.

 

Stuart