Problems plotting a function

5 Ansichten (letzte 30 Tage)
Sergio Manzetti
Sergio Manzetti am 7 Aug. 2017
Beantwortet: Star Strider am 7 Aug. 2017
Hi, I am trying to plot the result from the given script:
syms f(x) x g h
h = 1.0545718.*10.^-34
g = 5.33.*10.^-28
n = 2;
res = exp(-3.*x./2.*i.*g./h)
for k=1:n
res = simplify(diff(res,x) - x*res);
end
res = res
x = linspace(-10*pi, 10*pi, 1000);
s=res;
real_y1 = real(y);
imag_y1 = imag(y);
plot(real_y1,imag_y1,'LineWidth',2)
figure(1)
however, I get the strange complaint from Matlab:
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.
Error in Operator_SUSY_Psi (line 15)
plot(real_y1,imag_y1,'LineWidth',2)
Which plotting function should I use?
  1 Kommentar
Stephen23
Stephen23 am 7 Aug. 2017
You call plot with these variables:
real_y1 = real(y);
imag_y1 = imag(y);
plot(real_y1,imag_y1,'LineWidth',2)
but y is not defined anywhere in the code that you show us. So we have no idea what y is, other than it is clearly not numeric (as the error message clearly states).

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 7 Aug. 2017
First, define ‘h’ as:
h = 1.0545718E-34;
Second, see if this does what you want:
x = linspace(-10*pi, 10*pi, 1000);
y=double(res(x));
real_y1 = real(y);
imag_y1 = imag(y);
figure(1)
plot(real_y1,imag_y1,'LineWidth',2)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by