Plotting multiple graph in same graph
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mr. 206
el 12 de Sept. de 2018
Comentada: dpb
el 13 de Sept. de 2018
I am trying to plot all the graphs of each txt file in one graph. I am using this code but it is plotting them separately. Here is my code..
%Creating a continuous loop which will only stop after reaching j=size(READ,2)
c = 0;
%graphics_toolkit gnuplot
figure('visible','off');hold on
%This lopp will take column 1,3,5,7...............
for j = 1: 2 : size(READ,2)
c = c+1;
clf
x=READ(:,j);
y=READ(:,j+1);
plot(x_0,y_0)
end
hold off
end
0 comentarios
Respuesta aceptada
dpb
el 12 de Sept. de 2018
...
for j = 1: 2 : size(READ,2)
c = c+1;
clf
...
Well, you wipe out everything up to here--if the point is to add to the given figure, this defeats that.
clf is almost never needed in script or function; as a general rule forget it and cla and friends even exist; only when you discover a need go and dust them off...
8 comentarios
dpb
el 13 de Sept. de 2018
Inside the loop you need both directory names and to write to each after you've drawn the specific figure that belongs in that subdirectory.
You may find structuring the code to do this simpler if you encapsulate the existing code into its own function but with another couple of inputs; a flag as to whether to create multiple plots on a single figure (hold on) or to create a figure for each data set (hold off) and the name of the directory to use for output.
Then you could simply call that function from an outer loop with the control variables as wanted and not have to try to mung internally to the function itself.
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!