Plot ratio of 2 timeseries data on MATLAB

5 views (last 30 days)
Hi, I'm in the process of creating a plot of a variable Pr = Pideal/Pchange, whereas 'Pideal' are the timeseries values of ideal power output and Pchange are timeseries values of powerout subject to certain outage. Now as I do Pr = Pideal/Pchange, The MATLAB gives me an error. Here a1=zb1/z1 is the same as Pr = Pideal/Pchange.for plotting I just write plot (a1); I'm a beginner. Appreciate the help.
m2.PNG
m3.PNG
  2 Comments
Ankit
Ankit on 20 Sep 2019
normally it should work. Is it possible to upload your data as *.mat file?
thoughtGarden
thoughtGarden on 20 Sep 2019
Just confirmed that in general, this should work:
timeS1 = timeseries(linspace(1,2));
timeS2 = timeseries(linspace(1,5));
timeS1/timeS2
timeseries
Common Properties:
Name: 'unnamed'
Time: [100x1 double]
TimeInfo: [1x1 tsdata.timemetadata]
Data: [1x1x100 double]
DataInfo: [1x1 tsdata.datametadata]
More properties, Methods
though it is possible your timeseries are not the same length
timeS1 = timeseries(linspace(1,2));
timeS2 = timeseries(linspace(1,5,50));
timeS1/timeS2
Error using timeseries/utArithCommonTime (line 9)
Time series lengths are mismatched.
Error in timeseries/mrdivide>localmrdivide (line 58)
[commomTimeVector,outprops,warningFlag] = utArithCommonTime(ts1,ts2);
Error in / (line 26)
tsout = localmrdivide(ts1,ts2);

Sign in to comment.

Answers (1)

Jesús Zambrano
Jesús Zambrano on 6 Feb 2020
Hi Syed,
If you want to divide two vectors, use ./ command instead of / command.
This will do the division element-by-element. The two vectors should have the same size.
You can get more information by typing the following in the command window:
help ./
Best,
Jesús

Categories

Find more on Time Series in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!