why i m not able to get my figure
1 次查看(过去 30 天)
显示 更早的评论
clc;
clear;
clear all;
syms w a b c d s t x nu y
nu=0.33;
t=1;x=0;
a=-exp(2.*w.*t).*(-2.*t.^2.*w.^2+4.*exp(2.*w.*t).*nu-8.*nu.^2+2.*w.*t-3.*exp(2.*w.*t)+12*nu-5)./(w.^2.*(4.*exp(2.*w.*t).*t.^2.*w.^2+16.*exp(2.*w.*t).*nu.^2-24.*exp(2.*w.*t).*nu-4.*exp(4.*w.*t).*nu+10.*exp(2.*w.*t)+3.*exp(4.*w.*t)-4.*nu+3));
b=-exp(2.*w.*t).*(4.*exp(2.*w.*t).*nu+2.*w.*t-3.*exp(2.*w.*t)-1)/(w.*(4.*exp(2.*w.*t).*t.^2.*w.^2+16.*exp(2.*w.*t).*nu.^2-24.*exp(2.*w.*t).*nu-4.*exp(4.*w.*t).*nu+10.*exp(2.*w.*t)+3.*exp(4.*w.*t)-4.*nu+3));
c=(2.*exp(2.*w.*t).*t.^2.*w.^2+8.*exp(2.*w.*t).*nu.^2+2.*exp(2.*w.*t).*t.*w-12.*exp(2.*w.*t).*nu+5.*exp(2.*w.*t)-4.*nu+3)/(w.^2.*(4.*exp(2.*w.*t).*t.^2.*w.^2+16.*exp(2.*w.*t).*nu.^2-24.*exp(2.*w.*t).*nu-4.*exp(4.*w.*t).*nu+10.*exp(2.*w.*t)+3.*exp(4.*w.*t)-4.*nu+3));
d=-(2.*exp(2.*w.*t).*t.*w+exp(2.*w.*t)-4.*nu+3)/(w.*(4.*exp(2.*w.*t).*t.^2.*w.^2+16.*exp(2.*w.*t).*nu.^2-24.*exp(2.*w.*t).*nu-4.*exp(4.*w.*t).*nu+10.*exp(2.*w.*t)+3.*exp(4.*w.*t)-4.*nu+3));
f=@(w)w.^2.*cos(w.*y).*((a+(b.*0.5)).*exp(-w.*0.5))+((c+(d.*0.5)).*exp(w.*0.5));
step_size=0.001;
y=0:step_size:2;
r=0;
m=inf;
n=10;
h=(m-r)/n;
s=0.5*(f(r)+f(m));
for i=1:length(y)
s=s+f(r+i*h);
end
I=(h*s);
plot(y,I)
3 个评论
Jitender Gangwar
2018-11-26
Hi Gourav,
I am not sure what you are trying to do here but after looking at the code I notice that you have initialized m to inf which makes and h = inf, also f(inf) returns NaN and hence all the values of s in for-loop are also NaN which results in NaN for I.
You may want to change the initialization value of m and refer to the documentation of fplot for plotting symbolic expressions as I is symbolic.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!