Plot 3 graphs on same figure
Mostrar comentarios más antiguos
Hello,
From the code below, I wanted to get 3 plots on the same figure:
- Plot 1 will run the x time-axis from 1 to 10 vs the next 3 columns on the y-axis
- Plot 2 will run the x time-axis from 80 to 89 vs the next 3 columns on the y-axis
- Plot 3 will run the x time-axis from 100 to 109 vs the next 3 columns on the y-axis
clear;
clc;
[FileName,PathName] = uigetfile('*.txt','Select data file');
fid = fopen( strcat(PathName,FileName) ,'rt' );
% Read the file and store into matrix v
i = 0;
v = [0 0];
while feof(fid) == 0
buffer = fscanf(fid, '%f', 4);
buffer = buffer';
if i == 0;
v = buffer;
else
v = vertcat(v,buffer);
end
i = i + 1;
end
% Time vector
time = v(:,1);
% Number vector
number_1 = v(:,2);
number_2 = v(:,3);
number_3 = v(:,4);
%hold on
plot(time,number_1,'-ro', time,number_2,'-.b', time, number_3); grid on; axis([1 120 -67 -45]);
xlabel('Time (secs)'); ylabel('Current (mA)'); legend('number1','number2','number3')
curtick = get(gca, 'XTick');
set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
Can you help me to modify the code to get my desired output?
Thanks.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!