I got this error.
*??? In an assignment A(I) = B, thenumber of elements in B and I must be the same.Error in ==> readserial at 18 time(k)=str2num(out(13:17));*Here is my script:s = serial('COM2');set(s, 'baudrate', 38400)fopen(s)out = fscanf(s)%out='DATA,TIME,#,10006,1.49,1.50,0,0';
totaldata=500;time=zeros(1,totaldata);emg1=zeros(1,totaldata);emg2=zeros(1,totaldata);fsr1=zeros(1,totaldata);fsr2=zeros(1,totaldata);for k=1:totaldata out = fscanf(s) if out(11)=='#' time(k)=str2num(out(13:17)); emg1(k)=str2num(out(19:22)); emg2(k)=str2num(out(24:27)); fsr1(k)=str2num(out(29:29)); fsr2(k)=str2num(out(31:31)); endendfclose(s)
My intention is to collect data for 500 samples and sort it out to time, emg1, emg2, fsr1 and fsr2 throughout the process.
Thanks.
Best Answer