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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Piecewise function plot

ebelmonte
10-Marble

Piecewise function plot

Dear Mathcad community,

 

I have a problem when plotting a piecewise function.

The error is "all evaluations resulted in either an error or a complex result".

I would really appreciate if anyone can help me!

 

Thank-you very much.

 

Best Regards.


Enrico

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:ebelmonte)

The evaluation of:

F.input_rod(a)=

results in an error message "Must be scalar".

Tracing further back I find that in your definition of F.input_rod(a) you are comparing a with 10 m/s^2.

Note that a is an array, you cannot compare an array with a scalar value.

Your way out is simple: vectorize the F.input_rod(a) so that the function acts on each value, but still produces all results.

See attached.

 

Success!
Luc

View solution in original post

7 REPLIES 7
LucMeekes
23-Emerald III
(To:ebelmonte)

Can't see your sheet, unless you save as Mathcad 11..

 

Here's some advice to help you debug:

Evaluate the variable you want to plot. If you plot e.g. y(x) and have x defined (either as a range variable or as a vector), type

    y(x)=

and

    x=

To see the value(s) each has. There may be NaN's in there, or imaginary numbers. Or another error occurs.

In case of an error, select the evaluation and, using the righthand mouse button, select 'trace error', and trace that error back to where it occurs.

 

Success!
Luc

Dear Luc,

Thank-you for your reply.

Attached you find the file in .mcd format.

 

LucMeekes
23-Emerald III
(To:ebelmonte)

The evaluation of:

F.input_rod(a)=

results in an error message "Must be scalar".

Tracing further back I find that in your definition of F.input_rod(a) you are comparing a with 10 m/s^2.

Note that a is an array, you cannot compare an array with a scalar value.

Your way out is simple: vectorize the F.input_rod(a) so that the function acts on each value, but still produces all results.

See attached.

 

Success!
Luc

Just a quick look (in Smath), you have some unit balance issues.

LucMeekes
23-Emerald III
(To:Fred_Kohlhepp)

Where?

I don't see them. Mathcad (11) also not.

 

Luc

-MFra-
21-Topaz II
(To:ebelmonte)

Salve,

non puoi confrontare il vettore a con uno scalare. Il confronto con lo scalare va fatto elemento per elemento .

LucMeekes
23-Emerald III
(To:-MFra-)

Buona giornata,

Ecco di cosa si occupa la vettorializzazione.

 

Successo!
Luc

Announcements

Top Tags