How to get equation of signal in matlab

I want to find equation of this signal.
I plot this time series data and filter it with sSgolay filter. Now I want to get equation of this signal. Is this possible in matlab??
I have attached data of this plot with this post

4 Comments

There is NO "equation" for that signal, at least none that can be magically determined. In fact, there are an infinite number of completely useless "equations". This is not a question of possibility in MATLAB, but a question of possibility at all.
You need to learn about curvefitting, about modeling, approximation. All the topics of many books. Most importantly, you need to start thinking about what model is appropriate for this "curve". Then you need to learn how to estimate the model from your data.
You can get an equation for a neural network that models the I/O relationship.
HOWEVER, I don't see what good it will do
Greg
@Grej Thanks for your reply. I have not expertise in neural network. So I not know whether this network has created for such meteorological problems. In matlab I know there are some models like AR, ARMA which simulate the data set then forecast it. I tried them alot but unable to fit them due to lacking in expertise.
How can I forecast snow for one day ahead using this time series data set?
Thanks
help NARNET
doc NARNET
help NNCORR
doc NNCORR
greg NARNET
Hope this helps.
Greg

Sign in to comment.

 Accepted Answer

I am not certain what you intend by getting an equation for it.
You can filter out the noise to see the general trend:
fidi = fopen('data.txt','rt');
D = textscan(fidi, '%s%f', 'Delimiter','\t', 'CollectOutput',1);
t = datenum(D{1});
s = D{2};
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(t); % Signal Length
sm = s-mean(s); % Subtract Mean To Make Amplitudes At Frequencies>0 More Prominent
FTs = fft(sm)/L; % Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
Phs = angle(FTs);
figure(1)
plot(Fv, abs(FTs(Iv))*2)
grid
xlabel('Frequency (Days^{-1})')
ylabel('Amplitude')
set(gca, 'XLim',[0 0.05])
Wp = [0.0045]/Fn; % Passband Frequencies (Normalised)
Ws = [0.0055]/Fn; % Stopband Frequencies (Normalised)
Rp = 10; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby2(n,Rs,Ws); % Filter Design
[sosbp,gbp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(2)
freqz(sosbp, 2^16, Fs) % Filter Bode Plot
s_filt = filtfilt(sosbp,gbp, s); % Filter Signal
figure(3)
plot(t, s, '-b')
hold on
plot(t, s_filt, '-r', 'LineWidth',1.5)
hold off
xlabel('Time (Days)')
ylabel('Amplitude')
legend('Original', 'Lowpass Filtered')

8 Comments

Dear Sir, Thanks for your reply.
I am not certain what you intend by getting an equation for it.
I want to forecast my signal for 7 days ahead using this long term data set. I have this signal very long term data set. I want to forecast one week ahead values of its using this long term data set. Is this possible please?
This data set is of daily snow , general trend will not most suitable for getting value of snow for next 7 days.
I shall be very thankful to you for guiding well.
I doubt that it would be possible to forecast any one weather variable using only historical data from it.
You could try one of the learning algorithms to detect detailed trends, such as a neural network. When I tried the same sort of thing many years ago with a neural net (forecasting only two days ahead) using wind direction, barometric data, dewpoint, dry bulb temperature, and other variables, it failed miserably.
You will simply have to experiment.
Unfortunately, that is the best I can do.
Jan
Jan on 18 Jul 2017
Edited: Jan on 18 Jul 2017
@Muhammad: A forecast of daily snow fall for 7 days is a real challenge. I do not know any official institute or public service which can predict the rainfall for more than 3 days, and even in this short range the results are a rough probability only. Last week it has rained three times on a specific day at the place I work, but it was dry at my home, only 3 kilometers away. Then how is "rain" defined exactly? On a specific square meter or anywher in a region of 1 (10 or 100) square kilometers?
Your diagram looks very random on first view. Human are very powerful in recognizing patterns, but here I cannot see more than the low pass filtered trends determined by Star Strider's suggestion. +1
So try a neural network, but do not be disappointed, if the problem is to hard to be solved. I assume this is the nature of wheater.
@Star Strider, sir thanks for your reply. It really nice to hear that neural network may work for my problem. I have hear about AR,ARMA models in matlab and there are also some functions like simu, forecast, get trend etc which implement on data set. I tried them alot on my data set however i failed as i am not expert in these functions. An example of neural network and the above mentioned functions using same like problem will be very helpful for me.
Thanks for your kind assistance
dear @Jan Simon , thanks for your kind reply. Its really true nature is very tough to model. After getting from you its really fruitful for me if I able to get snow values only for one day ahead.
I have never work on neural network. I hear this NN but never deal with it practically.
I also find some functions in matlab, like AR, ARMA models, get trend, simulate, forecast. For initial documentations its looks to me might be these functions helpful in solving my problem. I need flow chart for these functions besides NN to deal with my problem.
Solved examples will be highly helpful for me. I will be thankful for this favor.
Usman
@Muhammad Usman Saleem —
The point of my comment is that the neural network did not work.
I encourage you either to thoroughly study meteorological models and their complexity, or to abandon this idea and consider a more tractable problem.
Thank you sir so much!
As always, my pleasure!
If my Answer helped solve your problem, please Accept it.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!