error in if else
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Jos (10584)
2018 年 2 月 26 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!