Creating an Array of X Values for Plotting a Function

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 3K views
airelemental135
Messages
13
Reaction score
0
I want to create a plot of a given function for all x values between negative infinite to negative R (for some given R value). How do I create an array for x so that my plot will include all the x values?
 
Physics news on Phys.org
airelemental135 said:
I want to create a plot of a given function for all x values between negative infinite to negative R (for some given R value). How do I create an array for x so that my plot will include all the x values?

You can't plot on a range [itex](-\infty,-R)[/itex] since Matlab won't accept Inf or NaN as valid points in the domain of a plot.

Of course, you can overcome this simply by compactifying the domain of your function to a finite domain, and then plotting the rescaled function over the new domain.