creating a new column in a matrix using 'if condition"
Ältere Kommentare anzeigen
On the following matrix:

I am using the following code which is not giving the right response.
if Reg1(:,3)==0
Reg1(:,10)=0;
else
Reg1(:,10)=a1-b1*Reg1(:,3)+Reg1(:,6);
end
Cannot figure out the issue.
The output is

1 Kommentar
Catalytic
am 26 Apr. 2019
We have no way of knowing what you consider to be the "right response"....
Akzeptierte Antwort
Weitere Antworten (1)
if all( Reg1(:,3)==0 )
Reg1(:,10)=0;
else
Reg1(:,10)=a1-b1*Reg1(:,3)+Reg1(:,6);
end
1 Kommentar
Milan Kumar
am 27 Apr. 2019
Kategorien
Mehr zu Matrix Indexing 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!