how to run 2 while loops in one script
Mostra commenti meno recenti
i have 2 scripts each with a while loop. the first script collects data every 10 minutes and the second script plots the collected data once a day. I have found that I cannot run two scripts at the same time in Matlab. Unless I install two different Matlab versions or I use the parallel computing tollbox, right?
Is there a way to run both while loops in one script?
unfortunately I can't attach the .dat1 file but I have attached the datalogger file from the second script.
Skript 1:
while true
tic
data=importdata('C:\Users\Hüs\Documents\MATLAB\Datalogger\KlimaLoggProAuto.dat1');
alle=[data(8,1);data(11,1);data(21,1);data(24,1);data(34,1);data(37,1);data(47,1);data(50,1);data(60,1);data(63,1);data(73,1);data(76,1);data(86,1);data(89,1);data(99,1);data(102,1)];
string(alle);
a=split(alle,'"');
Werte=a(:,2);
Werte=Werte';
Zeit=datetime('now');
Zeit=string(Zeit);
Werte=[Zeit Werte]; %the variable 'Werte' appears to change size on every loop iteration.
% Consider preallocating for speed. An other question: what can i do about this?
Werte=cellstr(Werte);
[succes,message]=xlsappend('Datalogger.xlsx',Werte,1);
pause(600-toc)
end
Skript 2:
while true
tic
table=readtable('C:\Users\Hüs\Documents\MATLAB\Datalogger\Datalogger.xlsx');
warning('off','all');
x=table.DatumUndUhrzeit; %Datum und Uhrzeit auslesen
x=x(end-468:end);
time=datetime(datestr((x)));
%Raum 210
temp210=table.Temp_R_210__C; %Temperatur Raum210 auslesen
temp210=temp210(end-468:end);
temp210=str2double(temp210);
hum210=table.Hum___; %Luftfeuchtigkeit Raum210 auslesen
hum210=hum210(end-468:end);
hum210=str2double(hum210);
f210=figure('Name','Room210','visible','off');
hold on;
yyaxis left;
plot(time,temp210);
yyaxis right;
plot(time,hum210);
yyaxis left;
title('Temperature and Humidity Room 210');
ylabel('Temperature in °C');
yyaxis right;
ylabel('Humidity in %');
xtickangle(45),
ax = gca();
ax.XTick = linspace(ax.XTick(1),ax.XTick(end),15);
saveas(f210,'Room210.jpg');
hold off;
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!