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

2 vues (au cours des 30 derniers jours)
SAM
SAM le 13 Avr 2023
Commenté : SAM le 13 Avr 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);

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 13 Avr 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)
  1 commentaire
SAM
SAM le 13 Avr 2023
I have been trying for a while.. Thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by