range in fplot as variables
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
clear
clf
clc
syms x y
f=x*y*(x+y);
ylim=[x^2 x];
ylow=ylim(1);
yup=ylim(2);
sol=solve(ylim(1)==ylim(2),x);
a=sol(1);
b=sol(2);
xlim=[a b];
integral=int(int(f,y,ylim(1),ylim(2)),x,xlim(1),xlim(2));
disp('The integral of f in the region enclosed is')
disp(integral)
fplot(ylow,[a b])
hold on
fplot(yup)
for p=xlim(1):0.01:xlim(2)
line([p p],subs(ylim,x,p),'Color','#abdbd4')
end
hold off
the job is pretty simple i want to show the regio of integration for a double integral in order dx dy
i have to generalize the above code for any function so that range in fplot should [a b]
although when i run the code it gives me this error
apparently if i give the range as [0 1]
it has no issues
but not all functions will have integrating region in a specific range say [0 5] (default)
why doesn't fplot takes [a b] as the range
0 Commenti
Risposta accettata
VBBV
il 7 Dic 2021
Modificato: VBBV
il 7 Dic 2021
clear
clf
clc
syms x y
f=x*y*(x+y);
ylim=[x^2 x]
ylow=ylim(1);
yup=ylim(2);
sol=solve(ylim(1)==ylim(2),x)
a=sol(1);
b=sol(2);
xlim=[a b];
I=int(int(f,y,ylim(1),ylim(2)),x,xlim(1),xlim(2));
disp('The integral of f in the region enclosed is')
disp(I)
fplot(ylow,[0 5])
hold on
fplot(yup,[0 5]) % specify the same range
axis([0 5 0 5])
for p=xlim(1):0.01:xlim(2)
line([p p],[subs(ylim,x,p)],'Color','red')
end
hold off
figure
for p=xlim(1):0.01:xlim(2)
line([p p],[subs(ylim,x,p)],'Color','red')
end
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Function Creation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!