Issue Plotting 2 different Values

4 Ansichten (letzte 30 Tage)
Cedric
Cedric am 5 Dez. 2022
Beantwortet: Shivansh am 13 Dez. 2022
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

Antworten (2)

Peter Perkins
Peter Perkins am 9 Dez. 2022
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 am 13 Dez. 2022
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.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by