Looping through arrays with equation out

조회 수: 1 (최근 30일)
Young Lee
Young Lee 2019년 9월 23일
답변: darova 2019년 9월 23일
Hi, I am trying to work on some large data 17200x2 ( need to construct temperature table before doing LSR )
with initial value To (temperature) = 1
a is constant
mV = milli volt
mVo = previous mV
let A= [ 0 1; 1 2; 2 3 ; 3 4; 4 5] % is timestep in second 0:0.001:17.2
and I need the following interations for n rows(17200)
my general function is (V-Vo/a) + To = T
so iter 1 , = To = 1
iter 2 , (2-1)/a + To = T1
iter 3 , ( 3-2)/a + T1 = T2
this should be recorded in column as looping
Here is what I have tried
mV = [A(:,1),A(:,4)]; % this is 17200x2 matrix
c = mV(:,2); % didnt quite work, so decided to extract single column 17200x1 to see if working for looping
for i = 1:length(c)
mt(i) = (c(i)-c(i-1))./(0.00005)+ mt % mt(temperature) needs to be recorded , for 17200 rows
end
THank you for any advise

답변 (1개)

darova
darova 2019년 9월 23일
I have a few suggections
112Untitled.png
  1. Index is forgotten
  2. When i=1 what value be in c(i-1)
  3. Assign first value for temperature before for loop
please use special button for code inserting
111Untitled.png

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by