Plot in a script with three time series, each series has to be a different color
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2020 年 4 月 20 日
...
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.
回答 (1 件)
Vimal Rathod
2020 年 4 月 23 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Map Display についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!