Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Matlab Coder - Passing Variables

조회 수: 3 (최근 30일)
Christian
Christian 2015년 1월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
I wrote a Code in Matlab in order to generate C-Code using the Matlab Coder. The Main function calls several other functions. E.g. Function A:
function [Calibration]=ReadCalib_ForCodeGen(file) %#codegen %Read in data temp=readfile(file);
ct=3; %Pass temp to another function endline=endlinedeterm(temp,ct);
end
function out=endlinedeterm(temp,ct) %#codegen out=0; for i=1:length(temp(ct,:))-1 if(temp(ct,i)==0 && temp(ct,i+1)==0) out=i-1; break; end end
end
The error I get during build is: Index expression out of bounds. Attempted to access element 3. The valid range is 1-1.
I didn't find a way around this problem. Do you have any suggestions?
  댓글 수: 2
Sara
Sara 2015년 1월 14일
Try
size(temp)
If the first value returned is smaller than 3, then temp(3,:) will trigger an error.
Ryan Livingston
Ryan Livingston 2015년 1월 14일
You should also see a link that says:
View Error Report
after the error. Click on that and you'll get a report showing your MATLAB code. Hover over temp to see what size MATLAB Coder thinks it is. It may be that it was determined that readfile returns a size different from what you are expecting.

답변 (0개)

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by