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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Plotting cosine failed, "replace complex values and NaNs by real numbers"

relayman357
11-Garnet

Plotting cosine failed, "replace complex values and NaNs by real numbers"

In attached file I'm trying to plot a function of time but am getting a "Replace complex values and NaNs by real numbers".  If I include units in my "t" range definition I can plot my second function.  If I exclude units I can plot my first function.  But not both at same time.  I can't see what is wrong.

 

pic.png

 

 

ACCEPTED SOLUTION

Accepted Solutions
ttokoro
20-Turquoise
(To:relayman357)

t with unit.  Then bottom plot can make.

image.png

View solution in original post

7 REPLIES 7
Werner_E
25-Diamond I
(To:relayman357)

Your range for t is defined unitless!

Thats OK with the unitless function v.AB, but in d(t) you use "d0" and "velocity" with correctly assigned units. So you have also to use a range for t with units as otherwise you run into a unit mismatch as you can't add feet and feet/seconds.

Define t:=0s,10^-6 s .. 0.01 s (you have to add a time unit to all three values).

Hi Werner,

 

Yes, and as you will see in my attached file, when I do define the units (exactly as you describe), then the bottom plot fails.  How do I correct that?

 

thank you

ttokoro
20-Turquoise
(To:relayman357)

t with unit.  Then bottom plot can make.

image.png

Werner_E
25-Diamond I
(To:Werner_E)

You had set up v.ab() without units, so you either change v.ab() that is uses unit (make the 60 to 60 Hz, etc.) or you have to use a unitless range for t.

 

On contrary you had set up d() to use units and so you either have to use a range for t with units or you divide by the unit seconds when it comes to plotting (as ppal and Terry had shown).

 

One of the benefits in using Mathcad or Prime is that it can handle units well and so I would recommend using correct units throughout. You may also consider using the predefined units microseconds and milliseconds:

Werner_E_0-1678355488072.png

 

ppal
17-Peridot
(To:relayman357)

ppal_0-1678336360268.png

 

Hi,

 

Distance is the integration of velocity.  The velocity varies so you need to do this.

Capture.JPG

Cheers

Terry

Hi Terry - in this case my Vab is a voltage, not a distance.  But, thank you.

Announcements

Top Tags