Plot in a script with three time series, each series has to be a different color
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I made a plot with three different time series, each series has to be plotted with lines and each series has a different color.
% temperature time series
% loading three different temperature gauges in
% North Carolina (Boone)
% loading temperature data from 3 different locations
tempdat = load('StreamTemp.dat');
col1 = tempdat(:,1);
tempdat = tempdat-32;
tempdat = tempdat * 5;
tempdat = tempdat / 9;
tempdat(:,1) = col1;
% plot the data we converted
x = col1;
y = tempdat(:,2:4);
plot(x,y);
xlabel('Time(days)');
ylabel('Temperature(C)');
title('Temperature Gauges in North Carolina');
1 comentario
dpb
el 20 de Abr. de 2020
...
col1 = tempdat(:,1);
tempdat = tempdat-32;
tempdat = tempdat * 5;
tempdat = tempdat / 9;
tempdat(:,1) = col1;
The above just writes the same data back to column one of the tempdat array because variable col1 was never modified---what you're looking for is:
tempdat(:,1)=5*(tempdat(:,1)-32)/9; % convert FtoC column 1 tempdat array
But, you follow this with
x = col1;
y = tempdat(:,2:4);
plot(x,y);
so it looks like column 1 isn't a temperature after all but maybe a time variable???
The plot call you have will draw three lines in different colors so that part of the question should be answered.
What we need to know is what the actual data in the file is as what you've written seems inconsistent at best.
Respuestas (1)
Vimal Rathod
el 23 de Abr. de 2020
Hi,
If you try to plot any two timeseries plots in the same plot using "hold on" you would always get plots with different colors and that would be automatically done by MATLAB.
But if you want to specify which color each plot should have, you could refer to the following link to know more about the color property of plot.
To know more about "hold" refer to the following link
Refer to the below link for more details on plotting timeseries data
0 comentarios
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!