why i m not able to get my figure

2 ビュー (過去 30 日間)
gourav pandey
gourav pandey 2018 年 11 月 14 日
コメント済み: gourav pandey 2021 年 4 月 5 日
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
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.
gourav pandey
gourav pandey 2021 年 4 月 5 日
Thank you so much for pointing out the mistake i have done.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by