How to plot a function over an interval of two functions?

2 visualizaciones (últimos 30 días)
SAM
SAM el 13 de Abr. de 2023
Comentada: SAM el 13 de Abr. de 2023
Hello,
I am trying to plot a symbolic function using fplot. I want to plot the function over an interval of two functions, but it is showing an error ''Too many functions''. Is there a way to solve this problem?
syms v
Ncrn1= 2.5429/v^2 + 0.3251*v^2;
fplot(v,Ncrn1,[0,9],'--')
Ncrn2=5.1624/v^2 + 0.0869*v^2;
fplot(v,Ncrn2,[0,9],'--')
Ncrn3=9.2372/v^2 + 0.0404*v^2;
fplot(v,Ncrn3,[0,9],'--')
hold on
int=solve(Ncrn2-Ncrn1==0,v)
inter1=int(real(int)>0&imag(int)==0);
fplot(v,Ncrn1,[0 inter1],'r','LineWidth',1.5);
hold on
int=solve(Ncrn3-Ncrn2==0,v);
inter2=int(real(int)>0&imag(int)==0);
fplot(v,Ncrn2,[inter1 inter2],'r','LineWidth',1.5);

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 13 de Abr. de 2023
Convert the solution obtained by solve() to double.
syms v
Ncrn1= 2.5429/v^2 + 0.3251*v^2;
fplot(v,Ncrn1,[0,9],'--')
Ncrn2=5.1624/v^2 + 0.0869*v^2;
fplot(v,Ncrn2,[0,9],'--')
Ncrn3=9.2372/v^2 + 0.0404*v^2;
fplot(v,Ncrn3,[0,9],'--')
hold on
int=solve(Ncrn2-Ncrn1==0,v);
%Conversion
inter1=double(int(real(int)>0&imag(int)==0))
inter1 = 1.8210
fplot(v,Ncrn1,[0 inter1],'r','LineWidth',1.5)
hold on
int=solve(Ncrn3-Ncrn2==0,v);
%Conversion
inter2=double(int(real(int)>0&imag(int)==0))
inter2 = 3.0596
fplot(v,Ncrn2,[inter1 inter2],'r','LineWidth',1.5)

Más respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by