# no output when coding

조회 수: 5(최근 30일)
Boss Man 10 Feb 2020
편집: Adam Danz 14 May 2020 17:25
for i=1:2363
dti=t(i+1)-t(i);
dt=(b(i+1)-b(i))/dti; % change in indoor temperature divided by time
c=dt/a(i)-b(i);
plot(c)
end
the idea is each time step is different so i want to divide the change in temp by each unique time step

#### 댓글 수: 5

표시 이전 댓글 수: 2
Boss Man 11 Feb 2020
still no plot
aim is to work out the difference between each time interval then divide the subsequent difference from dt to produce a graph
Copy of question
for i=1:2363
dti=t(i+1)-t(i);
dt=(b(i+1)-b(i))/dti; % change in indoor temperature divided by time
c=dt/a(i)-b(i);
plot(c)
end
the idea is each time step is different so i want to divide the change in temp by each unique time step
___________________________________________________________
My comment
Try
c = nan(1, 2363);
for i=1:2363
dti=t(i+1)-t(i);
dt=(b(i+1)-b(i))/dti; % change in indoor temperature divided by time
c(i)=dt/a(i)-b(i);
end
plot(c)
or
hold on
for i=1:2363
dti=t(i+1)-t(i);
dt=(b(i+1)-b(i))/dti; % change in indoor temperature divided by time
c=dt/a(i)-b(i);
plot(c, 'o')
end
Rena Berman 14 May 2020 17:05

로그인 to comment.

### 채택된 답변

Henry Gotjen 11 Feb 2020
편집: Henry Gotjen 11 Feb 2020
Do this without a for loop
a = a(:); b = b(:); t = t(:); % make sure we're working with column vectors
dti = diff(t) % difference between each value of t, length is one less than 1;
% it looks like your formula is the difference in db/dt divided by the difference between a and b.
% Pad db/dt with 0 so the array length matches with a and b.
c = [0; diff(b)./dt] ./ (a-b) ;
plot(t,c)
is this what you're trying to do?

#### 댓글 수: 4

표시 이전 댓글 수: 1
Boss Man 11 Feb 2020
I'm a bit confused now, this is the eq i'm trying to solve.
I need it to be consecutive values so i dont think rand would be useful to me.
so which of these codes would work?
Also why is it to end-1 and not end?
Stephen Cobeldick 11 Feb 2020
"I need it to be consecutive values so i dont think rand would be useful to me."
You did not provide a, b, or t, so Adam Danz quite reasonably just used some matrices of random values in order to actually run the code on something.
You should use your own arrays, of course, not the random values that are just used for testing.
Boss Man 11 Feb 2020
apologies, thought i attached the data

로그인 to comment.

### 추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

Translated by