Suggestion for rewrite of the for loop and while loop
Mostrar comentarios más antiguos
Hi, i have created a code. However, it takes very long execution time to execute the code.Can anyone suggest a better solution to improve on the code?Here is the code.
%To receive received=fgetl(s); %Get from serial port using fgetl
file=[file received]; %The received bits is joined together to form a stream of bits.
%To form back the file
size_byte=fix(size(file)/32);
M=size_byte(2);
Video=[];
for j=1:M %For loop to get the binary bits back to matrices format
b=16*(j);
a=-15+b;
Video= [Video;file(a:b)];
end
dec=bin2dec(Video);
fid1=fopen (Save_file, 'wb');
count=fwrite(fid1, dec, 'uint16');
I have run using the profiler and it stated is the fgetl and Video= [Video;file(a:b)];which cause alot of execution time.Can anyone help to suggest for a better solution?I need it urgently. Thanks.
3 comentarios
Jason Ross
el 25 de Abr. de 2011
What is "a long execution time"
How much data are you dealing with?
Jason Ross
el 25 de Abr. de 2011
Do you know how long you think it should take?
Do you have a performance limit you are required to meet?
MrPuzzled Marc
el 25 de Abr. de 2011
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Timing and presenting 2D and 3D stimuli en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!