I have following code want cp Vs ct plot. How to plot it
clc;
clear all;
close all;
format long;
syms cp positive
for ct=0:0.05:1;
eqn = (1.38/(cp/ct)^2)-0.4151-(ct^3/cp^2) == 0
Root=vpasolve(eqn,cp,[0 1])
end

 Respuesta aceptada

Star Strider
Star Strider el 4 de Sept. de 2020

0 votos

Try this:
format long;
syms cp positive
ctv=0:0.05:1;
for k = 1:numel(ctv)
ct = ctv(k);
eqn = (1.38/(cp/ct)^2)-0.4151-(ct^3/cp^2);
Root{k}=double(vpasolve(eqn,cp,[0 1]));
end
Root{cellfun(@isempty, Root)} = NaN;
figure
plot(ctv, [Root{:}])
grid
.

5 comentarios

Aiden James
Aiden James el 10 de Sept. de 2020
Hi sir, sorry for late comment. I have tried above code but it is showing following error. I am using matlab version 2015
Error using sym/subsasgn
Invalid indexing assignment.
Error in Untitled13 (line 7)
Root{k}=double(vpasolve(eqn,cp,[0 1]));
Star Strider
Star Strider el 10 de Sept. de 2020
It runs without error in R2020a. I no longer have access to any R2015 version.
If you run my code exactly as I wrote it, it should work.
Aiden James
Aiden James el 10 de Sept. de 2020
Hello sir, I just removed data type "double" from code. Now it is giving correct graph as expected. Thanks for your help. I may need more help in upcoming 1-2 months. Thanks agian.
Star Strider
Star Strider el 10 de Sept. de 2020
As always, my pleasure!
Aiden James
Aiden James el 17 de Sept. de 2020
sir,may be you can help me ,plesae refer following link for my query-
How to plot contour with constraints
https://in.mathworks.com/matlabcentral/answers/594670-how-to-plot-contour-with-constraints?s_tid=srchtitle

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Sept. de 2020

Comentada:

el 17 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by