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

2 次查看(过去 30 天)
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);

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-4-13
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by