필터 지우기
필터 지우기

fill up vector of matrices

조회 수: 3 (최근 30일)
Fiboehh
Fiboehh 2011년 5월 21일
Something very strange! I try to fill up a vector with matrices with values in read out of a microcontroller. The result is a vector with only the last element the correct matrix. The other elements is nothing in... And the read in of the values threw the microcontroller works perfect. Here my code :
for i=1:as %%make a vector with all zero's
data_inten{as} = zeros(rotations,16);
end
% read everything for every slice
for i=1:as
s=0;
inten = zeros(rotations,16)
for r=1:rotations
pause(0.1)
fwrite(u,'5') % send 5 to receive data
pause(0.4) % wait so every thing can be read
data = fread(u,34) % read in data from µC
j=0;
for k=2:2:32 % conversion of the binary data
str = dec2hex(data(k))
st = dec2hex(data(k+1))
string = strcat(st,str)
c = hex2dec(string)
inten(r,j+1) = c*610*10^-6 % fill up inten
j=j+1
end
end
data_inten{as} = inten; %%HERE SOMETHING goes wrong?!
text = [ 'Change height for ' int2str(ls) ' mm'];
uiwait(msgbox([ 'Change height'],'Wait','warn'));
end

채택된 답변

Daniel Shub
Daniel Shub 2011년 5월 21일
Your counter variable is i
for i=1:as ...
but you write
data_inten{as}
try
data_inten{i}
  댓글 수: 1
Fiboehh
Fiboehh 2011년 5월 21일
Jezus, so stupid of me. Seen over it :p
Thx man!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by