Azzera filtri
Azzera filtri

no output when coding

1 visualizzazione (ultimi 30 giorni)
Boss Man
Boss Man il 10 Feb 2020
Modificato: Adam Danz il 14 Mag 2020
a = xlsread('outdoorall.xlsx','H2:H52364');
b=xlsread('indoorall.xlsx','H2:H52364'); %2397
t=xlsread('outdoorall.xlsx','E2:E52364');% time in secs
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 Commenti
Adam Danz
Adam Danz il 11 Feb 2020
Modificato: Adam Danz il 14 Mag 2020
Copy of question
a = xlsread('outdoorall.xlsx','H2:H52364');
b=xlsread('indoorall.xlsx','H2:H52364'); %2397
t=xlsread('outdoorall.xlsx','E2:E52364');% time in secs
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
Rena Berman il 14 Mag 2020
(Answers Dev) Restored edit

Accedi per commentare.

Risposta accettata

Hank
Hank il 11 Feb 2020
Modificato: Hank il 11 Feb 2020
Do this without a for loop
% Load data
a = xlsread('outdoorall.xlsx','H2:H52364');
b=xlsread('indoorall.xlsx','H2:H52364'); %2397
t=xlsread('outdoorall.xlsx','E2:E52364');% time in secs
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 Commenti
Stephen23
Stephen23 il 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
Boss Man il 11 Feb 2020
apologies, thought i attached the data

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by