Matrices question (2)

Hi there,
I have a code which looks like this:
MATLAB code
vN=linspace(Phimin, Phimax, N);
for iN=1:length(vN)
Phi=vN(iN);
G(iN)=Phi + BOC;
C2(iN)=Rcon ./ ((Ccon .* cos(G(iN))) + (Scon .* sin(G(iN))));
C1(iN)=Rmax^2 + (C2(iN) .* cos(G(iN) + Thetamax));
A(iN)= (sqrt(abs(C1(iN)+C2(iN))) + sqrt(abs(C1(iN)-C2(iN))))./2;
B(iN)=C2(iN) ./ (2.*A(iN));
Fmax=0;
vP=linspace(Thetamin, Thetamax, P);
for iP= 1:length(vP)
Theta=vP(iP);
R(iP)= sqrt(C1(iN) - (C2(iN) .* cos(G(iN) + Theta)));
F(iN,iP)= abs(((R(iP).*(M*g*L)) .*cos(Theta)) /((A(iN).*B(iN)) .* sin(G(iN)+Theta)));
end
end
It allows me to determine variable F depending on value for variables phi and Theta, which are both matrices containing N and P terms respectively.
I would now like to determine what the maximum values of F are for a certain value of Phi-for example, if Phi=..., Theta=matrix of P terms, F=matrix of P terms, of which the maximum value is ...
I'd also like to store these values in a separate matrix, such as Fmax. With my code above, does anybodu have any advice as to go about doing this?

댓글 수: 3

Jan
Jan 2011년 10월 7일
Please use standard code formatting. Follow the "Markup help" link to learn more about formatting.
Nathan Edge
Nathan Edge 2011년 10월 7일
Hi,
Is that any better? Sorry about the confusion
Jan
Jan 2011년 10월 7일
This a little bit better, but not proper. Simply insert an empty line before the code block and two spaces before the code lines.

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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 10월 7일

0 개 추천

Phi = vN;
Theta = vP;
[vmx1,idx1] = max(F);
Fmaxphi = [vmx1;Phi(idx1);Theta];
[vmx2,idx2] = max(F,[],2);
Fmaxtheta = [vmx2,Phi,Theta(idx2)]';

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by