Negative number in Matrix or for loop or vector
Mostrar comentarios más antiguos
I have two questions.
first question.
I wrote the this CODE 1.
----------- CODE 1 -------------
x=zeros(25,2);
for t= -1 : 4
for k = -1 : 4
x(t,:)=[t,k]
end
end
------------------------------
but ! I'm not do that. because of error.
Error : ??? Subscript indices must either be real positive integers or logicals.
I want " x(t,:) = [t,k] " to get the negative number.
or !! Second question .
I wrote this CODE 2 .
------------CODE 2----------
x=zeros(25,2);
for t= 1 : 4
for k = 1 : 4
x(t,:)=[t,k]
end
end
----------------------------
And I get the result. that is the "Attach a file"
please see the "Attach a file"
so , I want each value to get the dependent or individual value. for EX) :
x =
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
...............................
4 3
4 4
please help me resolve the this problem. Thanks for your help.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!