Borrar filtros
Borrar filtros

Plot a 2 y axis graph

3 visualizaciones (últimos 30 días)
Anders Vigen
Anders Vigen el 7 de Feb. de 2021
Respondida: Srivardhan Gadila el 10 de Feb. de 2021
% Induction Factor
syms C_T C_P V D S E
idx = 0;
for a=(0:0.05:0.3333333)
idx = idx + 1;
C_T(idx)=4*a*(1-a)*etaTipLoss
C_P(idx) =4*a*(1-a)^2*etaTipLoss*etaDrag
% Car top speed formula
eqn(idx) = (C_P(idx)*etaTrans)/(C_T(idx)+(Ac/A)*CD+((M*g*fr)/((0.5*rho*Vinf^2*(1+V/Vinf)^2)*A))-C_P(idx)*etaTrans) == V/Vinf
S = double(solve(eqn(idx),V,"Real",true))
% V/Vinf
D = (S/Vinf)
end
plot([0:0.05:0.3333333],S,"-r")
hold on
yyaxis right
plot([0:0.05:0.3333333], D, "-.b")
hold off
I can't get the plot I want. I need to show my results for S and D where I want two y axis, because S and D dont have the same units. I hope there is someone that can help me correct my script.

Respuesta aceptada

Srivardhan Gadila
Srivardhan Gadila el 10 de Feb. de 2021
Refer to the documentation of yyaxis for more information. I was getting two Y-axes when I tried your code:
x = 0:0.05:0.3333333;
S = rand(size(x));
D = rand(size(x))/2;
% yyaxis left
plot(x,S,"-r")
hold on
yyaxis right
plot(x, D, "-.b")
hold off
If you want to set the same limits for both the Y-axes then you can try as below:
plot(x,S,"-r")
hold on
yleftLimits = get(gca,'ylim')
yyaxis right
plot(x, D, "-.b")
set(gca,'ylim',yleftLimits)
hold off
If this is not the issue you are facing, can you clearly state your issue with an example.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by