How can I use cubic spline to smooth data and sketch graphs.

2 views (last 30 days)
Hi.
I have large sets of data where I need to use cubic spline to apply smoothing and sketch the graph. In my data I need to find the average of total vertical electron content (VTEC) and come up with one hourly value using cubic spline and than sketch the against time for a period of 24hrs for every month. I'm new to matlab software and any help and suggestions is highly appriciated. Please find attached the set of sample data that i need to analyse for month of Feb. Thank you.
  2 Comments
John D'Errico
John D'Errico on 8 Nov 2021
Edited: John D'Errico on 8 Nov 2021
You don't use a cubic spline to average data at a given point. You really want to do that BEFORE you use a cubic spline.
Next, a cubic spline is typically an INTERPOLATING spline, so it won't smooth your data. It will pass directly through the data points.
Finally, you did NOT attach any data. You attached a small PICTURE of your data, which is completely useless unless someone were to try to type in your complete data set. I hope they have very good eyesight if they do. Is there a good reason why you want to make it more difficult for someone to help you?
If you really want help, then it would be best if you actually attach the true data. Do so either by pasting in the data as text, or by attaching a .mat file. A spreadsheet is also acceptable, but it takes slightly more effort for someone to read it in, IF they were going to try to help you. Again, is there a good reason why you want to make it difficult to get timely help? Please edit your question, or attach your data to a comment on your question. (Do not answer your question with the data, as many seem to do.)
Vikash Raj
Vikash Raj on 8 Nov 2021
Appologies for any inconvenience. I have attached the spreadsheet file. Please suggest any suitable method to analyse this data set. Thank you.

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 9 Nov 2021
hello
example of smoothing done on L1 data - FYI -
clc
clearvars
T = readtable('Feb 2020_Elv 50+.csv');
[samples,col] = size(T);
x = (0:samples-1);
L1 = T.L1;
L1s = smoothdata(L1,'movmedian',17);
plot(x,L1,x,L1s)
legend('raw','smoothdata')
  12 Comments
Mathieu NOE
Mathieu NOE on 12 Nov 2021
If you have the Curve fitting toolbox the csaps function (and others) are available

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!