필터 지우기
필터 지우기

using a nested for loop to walk through two matrix

조회 수: 1 (최근 30일)
SonOfAFather
SonOfAFather 2012년 11월 14일
Use a nested for loop to printout all values (one by one) for both S and T. To control your loops, use variables/numbers based on the results of using the size command.
S = [6 -10 4; 10 7 5; 3 9 5]
T = [-2 4 -10;3 -10 -8;-7 -5 7]
here is what i was thinking:
for s = 1:1:size(S)
for t = 1:1:size(T)
[s,t]
end
end
the problem with this is that the printout is only printing the index numbers not the actual matrix.
  댓글 수: 1
Jan
Jan 2012년 11월 14일
size(x) replies a vector, such that 1:size(x) will nbot necessarily reply what you expect. Use numel(x), length(x) or size(x, dim) instead.

댓글을 달려면 로그인하십시오.

채택된 답변

Harshit
Harshit 2012년 11월 14일
Use [S(s),T(t)] instead of [s,t]
  댓글 수: 1
SonOfAFather
SonOfAFather 2012년 11월 14일
thanks i thought that it must have been something simple.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by