Concatenate two strings in Matlab coder

I want to initialize two strings and concatenate them in Matlab , and produce C code using the Matlab Coder. Do I have to add a null terminator (0) to each of the strings before I pass them into coder.ceval('strcat',str1,str2) ?

답변 (1개)

Ryan Livingston
Ryan Livingston 2016년 9월 10일

3 개 추천

If you have strings in MATLAB, then just concatenate them in MATLAB:
str1 = 'foo';
str2 = 'bar';
str3 = [str1 str2];
MATLAB Coder will happily generate code for this.
If you're passing strings via coder.ceval then yes, you do have to null-terminate the strings since that is what strcat is expecting.
str1 = ['foo' 0];
str2 = ['bar' 0];
will do the trick.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

질문:

2016년 9월 8일

답변:

2016년 9월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by