Issue Plotting 2 different Values

1 view (last 30 days)
Cedric on 5 Dec 2022
Answered: Shivansh on 13 Dec 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

Answers (2)

Peter Perkins
Peter Perkins on 9 Dec 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");
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 on 13 Dec 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.


Find more on 2-D and 3-D Plots in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by