필터 지우기
필터 지우기

Can anybody help on this FOR loops

조회 수: 2 (최근 30일)
Murad Nuri
Murad Nuri 2020년 6월 5일
답변: madhan ravi 2020년 6월 5일
I do not really understand what exactly is wrong here.
I want to have the following variables give seperate results for each n.
Can you help me correct this?
for n = 1:N
Ln(n)=V(1:N,n)'*M*l
Mn(n)=V(1:N,n)'*M*V(1:N,n)
Gamma_n(n)=Ln/Mn
Mn_star(n)=Ln^2/Mn
fn_st(n)=Gamma_n.*M*V(1:N,n)
end
  댓글 수: 2
madhan ravi
madhan ravi 2020년 6월 5일
Does all the variables return a scalar in each iteration?
Murad Nuri
Murad Nuri 2020년 6월 5일
It does. But after each step of n, the previous value for the variable vanishes, this is not i want to have. I want for n=1 to have Ln(1), etc, for n=2 Ln(2), etc...

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

채택된 답변

madhan ravi
madhan ravi 2020년 6월 5일
[Ln, Mn, Gamma_n, Mn_star, fn_st] = zeros(N,1);
for n = 1:N
Ln(n)=V(1:N,n)'*M*l;
Mn(n)=V(1:N,n)'*M*V(1:N,n);
Gamma_n(n)=Ln(n)/Mn;
Mn_star(n)=Ln(n)^2/Mn;
fn_st(n)=Gamma_n(n).*M*V(1:N,n);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by