Trendfitting a series of downsamplings for comparisons

2 views (last 30 days)
Hi all!
I am looking to plot a series of downsamplings and then put an exponential to each to see if the downsampling manipulates data in an unfavorable way. The problem is, when attempting to plot multiple fit lines on one plot to compare the superimposed lines, I cannot control line style, color, nor name them, making a comparison pretty hard to read.
here is a snippet of the code, with an example of the full data, and a downsample of the data.
hold on
f = fit(u_image_time,transpose(median_intensity_pr),'exp2')
h=plot(f);
f1 = fit(downsample(u_image_time,3),transpose(downsample(median_intensity_pr,3)),'exp2')
h=plot(f1);
where this goes on for 5 downsamples with a total of 6 plot lines, not including their respective trendlines.
I was hoping to have a situation where the trend line and standard data would be the same color (or similar) with just different line styles, and have their corresponding titles displayed in a legend.
Below is kind of what I thought I'd do to accomplish it, but they only match up in color because i cannot control the trendline and it is defaulted to red.
f2 = fit(downsample(u_image_time,5),transpose(downsample(median_intensity_pr,5)),'exp2')
h=plot(f2);
h=plot(downsample(u_image_time,5),downsample(median_intensity_pr,5),'r', 'DisplayName', 'Downsample5');
xlim([1.4 30])
legend('location','best')
legend show
hold off
attached are the two .mats that will help this code run.
I appreciate all thoughts! Thanks!
Nick

Accepted Answer

Binaya
Binaya on 5 Oct 2023
Hi Nicholas,
I understand your requirement is to plot multiple down sampled and curve-fitted lines in a figure, each with distinct line styles and colors. Below, I have provided a sample code snippet that can serve as a reference:
hold on
f = fit(u_image_time,transpose(median_intensity_pr),'exp2')
h=plot(f,'b-');
f1 = fit(downsample(u_image_time,3),transpose(downsample(median_intensity_pr,3)),'exp2')
h=plot(f1,'r--');
Please find the documentation of plot function with linestyle and linecolor options here:
I hope this helps.
Regards
Binaya

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!