create function to plot several timeseries

조회 수: 2 (최근 30일)
Gaetano Pavone
Gaetano Pavone 2019년 10월 28일
댓글: Sahithi Kanumarlapudi 2019년 11월 1일
I have the following timeseries (only few rows are showed):
time.JPG
I have plotted such timeseries and then, by using the "Generate Code" option in the Plot Editor, I have obtained the following code:
function createfigure(ts_wave_heights_1, getcolumn1)
%CREATEFIGURE(ts_wave_heights_1, getcolumn1)
% TS_WAVE_HEIGHTS_1: vector of x data
% GETCOLUMN1: vector of y data
% Auto-generated by MATLAB on 28-Oct-2019 20:01:11
% Create figure
figure;
% Create axes
axes1 = axes('Position',[0.130732064421669 0.11 0.775 0.815]);
hold(axes1,'on');
% Create plot
plot(ts_wave_heights_1,getcolumn1,'Marker','.','LineStyle','none');
% Create ylabel
ylabel('wave height (m)','FontName','Times New Roman');
% Create title
title('Wave heigth 1');
box(axes1,'on');
% Set the remaining axes properties
set(axes1,'FontName','Times New Roman','FontSize',11,'XGrid','on','XTick',...
'XTickLabel',...
{'Jan-2015','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan-2016','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan-2017','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan-2018','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan-2019','Feb','Mar'},...
'XTickLabelRotation',45,'YGrid','on');
Now, I would like to recall this function for plotting different timeseries, for example ts_wave_heights_2. How can I do this?

채택된 답변

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2019년 10월 31일
You can call the function as you call any other function by passing the data to be plotted as input arguments to the function.
  댓글 수: 2
Gaetano Pavone
Gaetano Pavone 2019년 10월 31일
I don't understand what I have to define for getcolumn1
Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2019년 11월 1일
May I know what were you giving for 'getcolumn1' in your previous plot (what were considering for y-axis values)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by