Consider preallocating for speed
显示 更早的评论
Matlab tells me in line 11 to consider preallocating, but when I try to do it with line 7, matlab is still not happy with it. The value "Werte" is (1,16) in line 8 and in line 11 I add +1. I searched the forums but couldn't find a solution. What can i do?
1 while true
2 tic
3 data=importdata('C:\Users\Hüs\Documents\MATLAB\Datalogger\KlimaLoggProAuto.dat1');
4 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)];
5 string(alle);
6 a=split(alle,'"');
7 Werte=zeros(1,17); %preallocated value....might be unused.
8 Werte=a(:,2)';
9 Zeit=datetime('now');
10 Zeit=string(Zeit);
11 Werte=[Zeit Werte]; %Consider preallocating for speed.
12 Werte=cellstr(Werte);
13 [succes,message]=xlsappend('Datalogger.xlsx',Werte,1);
14 pause(600-toc)
15 end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!