Matrices question
이전 댓글 표시
Hi,
I have a script with two 'for' loops. Both of the loops involve matrices generated with 'linspace'-the first has N increments, and the second has P increments.
In the first loop, I have generated variables of the type A(N), B(N), etc. For the second loop, I want to craete a new variable of the type F(P,N). I am looking for F to be a matrix of P rows and N columns (or vise versa): however, I seem to be getting F to be a matrix of just one column. Does anybody have any advice?
EDIT: Sorry about the confusion, I'll post the code:
for Phi=linspace(Phimin, Phimax, N)
G(N)=Phi + BOC;
C2(N)=Rcon ./ ((Ccon .* cos(G(N))) + (Scon .* sin(G(N))));
C1(N)=Rmax^2 + (C2(N) .* cos(G(N) + Thetamax));
A(N)= (sqrt(abs(C1(N)+C2(N))) + sqrt(abs(C1(N)-C2(N))))./2;
B(N)=C2(N) ./ (2.*A(N));
for Theta=linspace(Thetamin, Thetamax, P)
F(N,P)= abs(((R(P).*(M*g*L)) .*cos(Theta)) /((A(N).*B(N)) .* sin(G(N)+Theta)));
disp(F(N,P))
end
end
BOC, Rcon. Ccon and Scon are all constants.
[EDITED, JSimon, 06-Oct-2011 09:27 UTC: Code formatted]
댓글 수: 2
Jan
2011년 10월 5일
Without seeing the code, only wild guessing is possible.
Please, Nathan, post the code instead of describing it.
Sean de Wolski
2011년 10월 5일
Well my attempt at a wild guess. You overwrite the first column on each iteration
for ii ...
for kk ...
d(1,:) = f(ii,kk)
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!