Filter löschen
Filter löschen

why i m not able to get my figure

1 Ansicht (letzte 30 Tage)
gourav pandey
gourav pandey am 14 Nov. 2018
Kommentiert: gourav pandey am 5 Apr. 2021
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 Kommentare
Jitender Gangwar
Jitender Gangwar am 26 Nov. 2018
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 am 5 Apr. 2021
Thank you so much for pointing out the mistake i have done.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by