Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Re: Piecewise function plot

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
10:18 AM

10-30-2019
10:18 AM

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

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
11:01 AM

10-30-2019
11:01 AM

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

7 REPLIES 7

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
10:34 AM

10-30-2019
10:34 AM

Re: Piecewise function plot

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
10:37 AM

10-30-2019
10:37 AM

Re: Piecewise function plot

Dear Luc,

Thank-you for your reply.

Attached you find the file in .mcd format.

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
11:01 AM

10-30-2019
11:01 AM

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
11:01 AM

10-30-2019
11:01 AM

Re: Piecewise function plot

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
12:01 PM

10-30-2019
12:01 PM

Re: Piecewise function plot

Where?

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

Luc

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
11:42 AM

10-30-2019
11:42 AM

Re: Piecewise function plot

Salve,

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-30-2019
11:58 AM

10-30-2019
11:58 AM

Re: Piecewise function plot

Buona giornata,

Ecco di cosa si occupa la vettorializzazione.

Successo!

Luc