Execution of for loop and indexing of strucutres
Ältere Kommentare anzeigen
Hi,
I am trying to run the following command inside a for loop:
if A(p,1)== B(:,1)
My question: Is every row of B is being compared to A in one running of the loop?
Regards, Waqas
5 Kommentare
Azzi Abdelmalek
am 10 Jul. 2015
Not clear
James Tursa
am 10 Jul. 2015
Can you show the loop indexing line also?
Waqas Syed
am 10 Jul. 2015
Bearbeitet: Image Analyst
am 10 Jul. 2015
James Tursa
am 10 Jul. 2015
Can you describe, in words, what this test is supposed to do?
if MainWPR_mpc.branch(p:1)== Reus.bus(:,1)
The (p:1) indexing definitely does not look right. Nor does the (p:2) indexing in the following line.
Waqas Syed
am 10 Jul. 2015
Akzeptierte Antwort
Weitere Antworten (1)
James Tursa
am 10 Jul. 2015
Bearbeitet: James Tursa
am 10 Jul. 2015
0 Stimmen
Is p the loop index?
A(p:1) could be empty or could be a scalar depending on what p is. B(:,1) is the first column of B. In an "if" test, the == would mean that all of the elemental results would need to be non-zero for the if-test to evaluate as true. I.e., all of the elements of the first B column would have to equal A(p:1) for the if-test to evaluate as true.
That being said, A(p:1) doesn't look right for what you probably intended and I would re-examine your code.
1 Kommentar
Waqas Syed
am 10 Jul. 2015
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!