Clear Filters
Clear Filters

Looping through arrays with equation out

1 view (last 30 days)
Young Lee
Young Lee on 23 Sep 2019
Answered: darova on 23 Sep 2019
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

Answers (1)

darova
darova on 23 Sep 2019
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

Categories

Find more on Performance and Memory in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!