Issue Plotting 2 different Values

3 次查看(过去 30 天)
Cedric
Cedric 2022-12-5
回答: Shivansh 2022-12-13
I have two excel files, the script extracts the data from the 2 files. I need to plot the water level for each specific year on y axis and ice conentration average on x axis. The script works for specific years but not for some because of not same vector size. The script finds the values range from 1st of october to the 1st of october of the other year. Any help on how i could do that better
Thanks

回答(2 个)

Peter Perkins
Peter Perkins 2022-12-9
Cedric, I can't really follow your code or your explanation, but I would think you want something like this:
ice = readtimetable("Ice concentration data.csv")
opts = detectImportOptions("15330-01-JAN-1970_slev.csv",Delimiter=',',NumHeaderLines=7);
opts = setvaropts(opts,"Obs_date",Type="datetime",InputFormat="uuuu/MM/dd");
water = readtimetable("15330-01-JAN-1970_slev.csv",opts)
Throw away water data outside the range of the ice data.
water = water(timerange(min(ice.DateTime),max(ice.DateTime)),:);
Fill in the ice data with missing values and plot.
ice = retime(ice,water.Obs_date,"fillwithmissing");
plot(ice.Conc_Ice_Avg,water.SLEV_metres_,'o')
If your goal is to overlay all the years on top of each other, thatneeds a few more steps, but your description doesn't seem to say say that.

Shivansh
Shivansh 2022-12-13
Hi ,
According to my understanding , you are not able to plot scatter plot because of the difference in size of two arrays i:e "Ice_Conc_values_for_this_specific_year" and "Pointe_Claire_Water_Level_values". This issue is arising because you have interpolated the "Ice concentration data" using "retime" function but have not interpolated the cell array "A" which contains water level. The possible workaround is to interpolate cell array "A" as well using retime function so that size of two arrays remain same.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by