Removing cell arrays from code

조회 수: 6 (최근 30일)
Jess
Jess 2013년 2월 13일
Hi all,
I am working on some Matlab scripts which require converting to C. I plan on doing that using Matlab Coder, and therefore I need to eliminate features such as cell arrays and function handles as Matlab Coder can't work with them.
I would just like some advice regarding cell arrays. Would the best way of eliminating them be using structures in the code instead?
E.g. converting
mystrings = {'name','surname'};
to
mystrings(1).name = 'name'; mystrings(2).surname = 'surname';
Am I going the right way thinking about this?
Thank you!

채택된 답변

Thorsten
Thorsten 2013년 2월 13일
Yes.

추가 답변 (1개)

Bill Chou
Bill Chou 2013년 2월 19일
That's correct, essentially, convert your cell arrays into structs and you'll be all set. So I'd use:
mystrings(1).name = 'name'; mystrings(1).surname = 'surname';

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by