if condition for Matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Osamah Alayafi
am 31 Mai 2021
Beantwortet: Steven Lord
am 31 Mai 2021
I have Matrix for example
M = ones(10,10)
how I make ( if condition) s.t
M(i-tau,j)=0 if i-tau <0,
where i =1:10 and j =1:10
Thanks
1 Kommentar
Torsten
am 31 Mai 2021
M(i-tau,j) does not exist if (i-tau)<0. So you can't set it to a specified value ( 0 in this case ).
Akzeptierte Antwort
Steven Lord
am 31 Mai 2021
M(i-tau,j)=0 if i-tau <0,
There's no such thing as row -1 of a matrix in MATLAB. Depending on what you're trying to do you could limit the values of i over which you iterate to those that make i-tau a positive integer value or you could detect the condition where i-tau is negative (actually you'd want to detect when it's non-positive since there's no such thing as row 0 in a matrix in MATLAB either. The first row in a matrix in MATLAB is row 1.) and skip attempting to index into M entirely.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!