Problems plotting a function
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2017-8-7
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).
回答(1 个)
Star Strider
2017-8-7
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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!