i heave this error whit the code, i don´t know why, i suposed is a problem whit the datatype but i don´t know why this is the error: In an assignment A(I) = B, the number of elements in B and I must be the same. Error in ADC_serialPort_K64F_V6 (line 30) v(ctr) = (value_mf); oohh, i use a serial cmunication, 8 bits, when the voltaje is higher than 0 volts, it works, example if a conected 3 volts in the microcontroller adc, it works, but when the voltaje is under the 0 volts or close (i suposed close) it doesn´t work, thank you. this is the code:
while ctr <= i
value_mf = fscanf(Datos,'%d',1) ;
v(ctr) = (value_mf);
v(ctr) = (v(ctr)*3.3/256);
if v(ctr)>3.3
v(ctr) = v(ctr - 1);
end
ctr=ctr+1;
end

 채택된 답변

Roger Stafford
Roger Stafford 2015년 4월 23일

0 개 추천

The problem here is that 'ctr' of v(ctr) is not the same size as whatever the output of 'fscanf' is at that point, so matlab doesn't know how to proceed with the assignment. I am guessing 'ctr' is a scalar quantity and 'fscanf' is outputting something with multiple elements. If so, how is matlab to stuff many elements into a single element?

댓글 수: 1

Ricardo  De Santiago
Ricardo De Santiago 2015년 4월 24일
oohh, in effect, then i can use another variable, or convert the output of fscanf? well, it´s helpful reply, thank you

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by