Adding strings in simulink
1 次查看(过去 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;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Block Libraries 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!