필터 지우기
필터 지우기

why i m not able to get my figure

조회 수: 3 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by