I am trying to plot two functions in one plot (not working)

3 visualizaciones (últimos 30 días)
I am trying to plot two functions in one graph and it not working for some reason. I tried to put dots for mutiplications and divisions but it is still not working. Some error appears and i can't fix it, please help

Respuesta aceptada

Pier Giorgio Petrolini
Pier Giorgio Petrolini el 25 de Nov. de 2020
Hello Mahmoud,
I can't see all your code, so I have to assume that all the rest is correct and, that you need to plot the functions "deltaP_AtoB1" and "deltaP_AtoB2" against the variable "V_c", correct ?! Try to rewrite the commands as follow:
Case 1) V_c = linspace(0,1,15)
deltaP_AtoB1 = ...
deltaP_AtoB2 = ...
plot(V_c, deltaP_AtoB1)
hold on
plot(V_c, deltaP_AtoB2)
hold off
===> in that case you need to use dots as you perfectly did because you're operating with vectors but you don't need to define deltaP_AtoB as symbolic variable, unless you need it after.
Case 2) Define V_c as a symbolic variable
deltaP_AtoB1 = ...
deltaP_AtoB2 = ...
fplot(V_c, deltaP_AtoB1)
hold on
fplot(V_c, deltaP_AtoB2)
hold off
xlim([0 15]) % eventually
==> in that case you don't need to use dots
I hope it helps, let me know if it works.
Kind regards,
PGP
  1 comentario
Mahmoud Alshaghab
Mahmoud Alshaghab el 28 de Nov. de 2020
I used fplot and it worked,
I didn;t try your suggestion, but thank you so much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by