Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How do I use a for loop?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I'm currently trying to make an approximation method in matlab, and this is what I have currently:
function T = Dog(A,S)
L=randi([-9,9],3,1);
H=L/norm(L);
O=(inv((A-(A(3,3)*eye(3)))))*(H);
Y=O/norm(O);
G=(inv((A-(A(3,3)*eye(3)))))*(Y);
D=G/norm(G);
F=(inv((A-(A(3,3)*eye(3)))))*(D);
R=F/norm(F);
W=(inv((A-(A(3,3)*eye(3)))))*(R);
X=W/norm(W);
V=(inv((A-(A(3,3)*eye(3)))))*(X);
K=V/norm(V);
N=(K.*K)./(K.*V);
T=N+S;
end
Now I was wondering is there someway of using a for loop from lines 3 to 13, so that instead of having to change the name of the variable each time it would simply replace it with with the one that came before it?
댓글 수: 1
답변 (1개)
Thorsten
2017년 3월 17일
편집: Thorsten
2017년 3월 17일
F=randn(3,1)./W;
for i = 1:5
Q = inv(A - S*eye(3))*F;
F = W./Q;
W = Q;
end
J = (F.*F)./(Q.*F);
T = J + S;
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!