Adding strings in simulink
10 ビュー (過去 30 日間)
古いコメントを表示
I'm using a simulink matlab function for the following code:
function [e1s,e2s,crits,users] = fcn(error1,error2)
n=32;
e1 = int2bit(error1,n,true);
e1r = reshape(e1,[8,4]);
e1s = flipud(e1r');
e2 = int2bit(error2,n,true);
e2r = reshape(e2,[8,4]);
e2s = flipud(e2r');
%% error to dashboard part
crits="Critical error:";
users="User error: ";
crits =crits + " test";
I get the following two errors however:
Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
Component:MATLAB Function | Category:Coder error
Size mismatch (size [1 x 15] ~= size [1 x 20]) in field 'Value'. Function 'MATLAB Function' (#89.286.291), line 17, column 1: "crits" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
I don't understand why the output size suddenly is a vector. Is it just that simulink doesn't like strings?
0 件のコメント
回答 (1 件)
Walter Roberson
2023 年 2 月 21 日
you are resizing the string. string literals do not appear to be dynamically sized.
Use a different variable name the first time you assign to crits such as
cbm = "Critical error: ";
crits = cbm + test;
1 件のコメント
参考
カテゴリ
Help Center および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!