Plotting a graph properly

%code for plotting the real values of wetted radius vs time
WR_real = real(WR);
WR_real(valid) = 0;
plot(timeSec(:,:,1),WR_real(:,:,1),'LineWidth',2)
xlabel ('Time (s)')
ylabel ('Wetted Radius (m)')
title ('Wetted Radius vs Evaporation Time')
legend('Theoretical')
Hello everyone,
I want to plot a graph and I used the attached code. However, I want to get rid of the vertical blue line on the y axis and the horizontal blue line on the x axis. I am not quite sure how this happened. Does anyone know how to solve this problem?
Thanks and regards

1 comentario

KSSV
KSSV el 22 de Jul. de 2020
You skip the first value and then plot.

Iniciar sesión para comentar.

 Respuesta aceptada

Arthur Roué
Arthur Roué el 22 de Jul. de 2020

0 votos

%% Plotting
%code for plotting the real values of volume vs time
V_real = real(V);
valid = V_real<0;
V_real(valid) = 0;
plot(timeSec, V_real,'LineWidth',2)
xlabel ('Time (s)')
ylabel ('Volume (m^3)')
title ('Volume vs Evaporation Time')
legend('Theoretical')
%code for plotting the real values of wetted radius vs time
WR_real = real(WR);
WR_real(valid) = 0;
vb = WR_real ~= 0; % find 0 to remove them
plot(timeSec, WR_real,'LineWidth',2); hold on
plot(timeSec(vb), WR_real(vb),'LineWidth',2)
xlabel ('Time (s)')
ylabel ('Wetted Radius (m)')
title ('Wetted Radius vs Evaporation Time')
legend('Theoretical')

3 comentarios

AB
AB el 22 de Jul. de 2020
Thank you for your help. I tried your code but I'm still getting this blue line for some reason and the red isnt converging to 0 on the x axis
Arthur Roué
Arthur Roué el 22 de Jul. de 2020
I superpose the curve without the zero with a second plot.
plot(timeSec, WR_real,'LineWidth',2); hold on % Original curve, hold on for superposition in axe
plot(timeSec(vb), WR_real(vb),'LineWidth',2) % Curve without zero
Red is'nt going to zero because I also removed this zero. You need to process your data to keep this zero.
AB
AB el 22 de Jul. de 2020
ahh okay thank you for your help :)

Iniciar sesión para comentar.

Más respuestas (1)

Arthur Roué
Arthur Roué el 22 de Jul. de 2020
Editada: Arthur Roué el 22 de Jul. de 2020

0 votos

This happens because your data looks like that :
WR_real(:,:,1) = [0 1.1 ... 0.2 0 0]*1e-3
To get rid of those lines, remove the zeros at the beginning and the end of your data (and in time vector too to match size)

2 comentarios

AB
AB el 22 de Jul. de 2020
Thank you for your answer but how do I remove the zeros?
I am a bit confused
Arthur Roué
Arthur Roué el 22 de Jul. de 2020
Editada: Arthur Roué el 22 de Jul. de 2020
In your case, it seems the zeros are only at the end and beginning. Then you can remove all 0 this way :
% Get index of 0
vb = WR_real(:,:,1) ~= 0
% Plot without the 0
plot(timeSec(vb,:,1),WR_real(vb,:,1),'LineWidth',2)
EDIT : Why WR_real got 3 dimension ?

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2019a

Preguntada:

AB
el 22 de Jul. de 2020

Comentada:

AB
el 22 de Jul. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by