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);
0 个评论
采纳的回答
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))
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))
fplot(v,Ncrn2,[inter1 inter2],'r','LineWidth',1.5)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!