Real Time Matlab Graphing
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have an excel file that updates every minute and I imported it into matlab with this code...
fid=fopen('CR1000_PU22_TTT_15sec_new1.csv');
c=textscan(fid,'%s %f %f %f %f %f %f %f %f %f %f %f','CommentStyle',...
{',,Min,Smp,Avg,Avg,Avg,Avg,Avg,Avg,Avg,Avg'},...
'delimiter',',','EmptyValue',nan);
c{1,1}=strrep(c{1,1},'UTC','');
CR1000_PU22_TTT_15sec.time=datenum(c{1,1},'dd/mm/yyyy HH:MM');
CR1000_PU22_TTT_15sec.HF_Highest=c{1,5};CR1000_PU22_TTT_15sec.HF_Middle=c{1,6};CR1000_PU22_TTT_15sec.HF_Low=c{1,7};
CR1000_PU22_TTT_15sec.TC_Highest=c{1,8};CR1000_PU22_TTT_15sec.TC_Middle=c{1,9};CR1000_PU22_TTT_15sec.TC_Low=c{1,10};
CR1000_PU22_TTT_15sec.TC_Wall_Surface=c{1,11};CR1000_PU22_TTT_15sec.TC_Plenum_Air=c{1,12};
clear c fid
...so the data is in a structure. If the excel data is constantly being updated. Can I make a graph that is constantly changing with the new data as well. If so how would I do this?
0 comentarios
Respuesta aceptada
John Petersen
el 26 de Jul. de 2012
Editada: John Petersen
el 26 de Jul. de 2012
Here's an example of plotting one parameter. You don't really need the comparison of datenum with current since I put in a pause of 60s, but it is a check to see that the file really was updated. pos is used to read the file to the next line of data. I'm assuming the new data is appended to the file, which is why I increment pos each time. Not sure if this will load down your computer, but I'm hoping pause is really a sleep task:
pausetime = 60;
dirname = 'c:\myCR1000data\'; % example of directory
filename = 'CR1000_PU22_TTT_15sec_new1.csv';
file = dir(filename);
current = file.datenum;
f = figure;
pos = 1; % initial data line in file
while(1)
file = dir(filename);
if (file.datenum > current)
fid=fopen(filename);
c = textscan(fid,'%s %f %f %f %f %f %f %f %f %f %f %f',...
pos,...
'CommentStyle',...
{',,Min,Smp,Avg,Avg,Avg,Avg,Avg,Avg,Avg,Avg'},...
'delimiter',',','EmptyValue',nan);
fclose(fid);
pos = pos + 1;
c{1,1}=strrep(c{1,1},'UTC','');
CR1000_PU22_TTT_15sec.time = datenum(c{1,1},'dd/mm/yyyy HH:MM');
CR1000_PU22_TTT_15sec.HF_Low = c{1,7};
plot(f,CR1000_PU22_TTT_15sec.time, CR1000_PU22_TTT_15sec.HF_Low);
hold(f, 'on');
end
current = file.datenum;
pause(pausetime);
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!