Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-0.

if ~isempty(instrfind)
fclose(instrfind);
delete(instrfind);
end
A = zeros(64,1);
B = zeros(64,1);
C = zeros(64,1);
D = zeros(64,1);
Arduino=serial('COM3','BaudRate',9600);
fopen(Arduino);
writedata=uint16(500); %0x01F4
fwrite(Arduino,writedata,'uint16') %write datac
for i=1:64 %read 64 lines of data
A(i,:) = fscanf(Arduino,'%f');
end
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-0.
Error in testing (line 15)
A(i,:) = fscanf(Arduino,'%f');

 採用された回答

KSSV
KSSV 2020 年 8 月 26 日
Try:
count = 0 ;
A = zeros([],1) ;
for i=1:64 %read 64 lines of data
temp = fscanf(Arduino,'%f') ;
if ~isempty(temp)
count = count+1 ;
A(count,:) = temp ;
end
end

3 件のコメント

No errors but nothing appeared it just moved to a next line. Do you know how to show the data from there ?
KSSV
KSSV 2020 年 8 月 26 日
Is data not stored in A?
ohh yeah ur right. Thanks alot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で MATLAB Support Package for Arduino Hardware についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by