Trend analysis
9 views (last 30 days)
Show older comments
Hello everyone here is my problem
function trend
Data=xlsread('datatrend.xlsx');
D=Data(:,1);
for i=1:10;
t=D(i,1);
for j=(i+1):10;
x=t-D(j,1);
y=sign(x);
end
end
end
The thing I am trying to do is this:
I need to write a code that will do some calculation on a matrix that has 1 column and more than 10 rows ( row number can change ). I divide the calculations in to the steps;
a. Firstly it should take first row and substract second row from it so "R1-R2" basically
b. If the outcome of the substraction is positive it should take variable as 1, if the outcome is negative it should take variable as -1 and if the outcome is 0 it should take variable as 0
c. The program need to do above for "R1-R3", "R1-R4" so in short it should substract each row from "Row1" and determine what the variable will be
d. After this step is done for "Row1" it should now do it for "Row2" which includes same as step "c" and substract all rows from "Row2" except it shouldn't substract any row above "Row2" from it. For example like "R2-R3" , "R2-R4" and so on.
e. Same steps for "Row3". "R3-R4", "R3-R5" ....
f. So overall it should do these substractions and sum up all the 1,0,-1 that has been recorded from it and give me a summation
I'd much appreciate if anyone can help me on this I got the basic idea of how to write it but can not get any result out of it:S
0 Comments
Answers (2)
Daniel Shub
on 28 Apr 2012
I haven't read your whole question, but the code looks a little suspicious to me. Are you sure you do not want
y(i,j)=sign(x);
currently your code just keeps writing over y.
0 Comments
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction 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!