Filter löschen
Filter löschen

why won't this code run?

3 Ansichten (letzte 30 Tage)
LM
LM am 23 Nov. 2017
Kommentiert: LM am 23 Nov. 2017
[find(stock.permno)]==notrading(1);
for i=1:18522
end
for j=10137
newt=[find(toremove(i)==c)],:)=[];
end
for i=0:4
t((1+(i*126)):(126+(i*126)),:)=c((253+(i*378)):(379+(i*378)),:);
end
for i=1:5
trade(i).permno=top5(i,1);
for ii=0:4
trade(ii+1).price=d(1+(ii*252):252+(ii*252),4);
end
  1 Kommentar
KSSV
KSSV am 23 Nov. 2017
How did you run? What error you got?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Bshara Murr
Bshara Murr am 23 Nov. 2017
Bearbeitet: Bshara Murr am 23 Nov. 2017
Probably because you used the same local variable inside the main and nested loop. Try replacing the second i by a j (in every instance you are referring to it), and end your "for" loops.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 23 Nov. 2017
You have
newt=[find(toremove(i)==c)],:)=[];
which attempts to do two assignments in one statement.
  3 Kommentare
Walter Roberson
Walter Roberson am 23 Nov. 2017
Possibly you want
newt(find(toremove(i)==c),:)=[];
but it is difficult to be sure as your code does not mention newt anywhere else.
LM
LM am 23 Nov. 2017
got another error once i fixed it saying find has too many input arguments

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by