error in if else
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jos (10584)
il 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 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!