필터 지우기
필터 지우기

Can i use cell inside user defined Matlab function in Simulink?

조회 수: 2 (최근 30일)
nithesh k
nithesh k 2017년 3월 7일
답변: Astarag Chattopadhyay 2017년 3월 13일
function y = fcn(u)
%#codegen
A=cell(1,4);
p=zeros(3,12);
for i=1:4
A{:,i}=rotx(u(i));
end
p=cell2mat(A);
y=reshape(p,[3,12]);
end
function R = rotx(t)
ct = cos(t);
st = sin(t);
R = [
1 0 0
0 ct -st
0 st ct
];
end
I am trying to use cell and cell2mat inside a user defined Matlab function in Simulink. The above code (function y = fcn(u)) gives error "The function 'cell2mat' is not supported for standalone code generation". How can i proceed to use cell and extract it as matrix for simulink?

답변 (1개)

Astarag Chattopadhyay
Astarag Chattopadhyay 2017년 3월 13일
I understand that you want to generate C code from this MATLAB function. However, cell arrays are not supported for code generation. A workaround would be to use structures in place of cell arrays as code generation for structures is supported.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by