Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Looping through a result

조회 수: 3 (최근 30일)
Camilo Granda
Camilo Granda 2017년 10월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
Hey everyone, I have the variables P_initial and V_initial which are initial conditions given and use to compute the G_initial. After this, on each iteration G_ith is multlpied by a factor delta and this new G_ith is used to compute V_ith and P_ith. How can I create a loop that after the first evalaution of G_inital used this result to compute P_2, V_2 which later on I use this values to compute G_2 and so on? What I am trying to do is shown in the image
Thanks

답변 (1개)

KSSV
KSSV 2017년 10월 10일
N = 100 ; % total steps
delta = rand ; % delta
x = zeros(N,1) ;
y = zeros(N,1) ;
% a randpom intial value
x(1) = rand ;
y(1) = rand ;
for k = 2:N
x(k) = x(k-1)+delta*y(k-1) ;
y(k) = y(k-1)-delta*x(k) ;
end

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by