필터 지우기
필터 지우기

Plot in a script with three time series, each series has to be a different color

조회 수: 2 (최근 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
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
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

카테고리

Help CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by