error in if else
6 views (last 30 days)
Show older comments
I have two files with 252 rows and 1 coloumn. I am trying to implement this for loop with if else condition but getting error(Error: File: v.m Line: 509 Column: 13 Unbalanced or unexpected parenthesis or bracket.). Can you please help? cbob and wti are the 2 csv files(attached) which I have imported using import data in Matlab.
if true
portfolio=zeros(253,1);
for i=1:252
if (cbob [i] > 72)
portfolio[i]= 72 ;
else portfolio[i]= CBOB[i] ;
else if(wti[i]>60)
portfolio[i]=wti[i];
else portfolio[i]=60;
end
end
0 Comments
Answers (1)
Jos (10584)
on 26 Feb 2018
In Matlab, indexing is done by round brackets, and concatenation by square brackets:
A = [1 2 3]
B = [A 4 5] % concatenation
B(4) % indexing
so
if cbob(i) > 72
...
0 Comments
See Also
Categories
Find more on Matrix Indexing 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!