How do I pass a variable into a function containing a cell array?
1 回表示 (過去 30 日間)
古いコメントを表示
I'm attempting to pass a variable into the following function;
function Test_Message_Body_Builder(BLength)
f = figure('Name', 'Message Builder', 'numbertitle', 'off', 'Position', [100 100 1450 700], 'resize', 'off');
t = uitable('Parent', f, 'Position', [25 25 840 300]);
DefaultData = {'Fmt:' '19 (PLAYBACK)' 'Length:' BLength 'Remote Num:' 0 ' ' ' ' ' ' ' '};
set(t, 'Data', DefaultData);
set(t, 'ColumnFormat', char);
set(t, 'ColumnWidth', {160, 160, 160, 160, 160, 160, 160, 160, 160, 160});
set(t, 'RowName', []);
set(t, 'Position', [0 0 1450 700]);
foregroundColor = [1 1 1];
set(t, 'ForegroundColor', foregroundColor);
backgroundColor = [.4 .1 .1; .1 .1 .4];
set(t, 'BackgroundColor', backgroundColor);
set(t, 'ColumnEditable', [true true true true true true true true true true]);
set(t, 'ColumnFormat', {[] []});
set(t, 'CellEditCallBack', @ValueChange);
% Assign default ComplexData to the base Work Space
assignin('base', 'Default_Message_Body_Values', DefaultData);
end
Where the variable, BLength, is a 1 x 1 double. Once executed, the table displays a default set of values/characters which can be edited by the user during testing.
However, when I try to run the function, I get the following error;
>> BLength = 704;
>> run Test_Message_Body_Builder
Error using Test_Message_Body_Builder (line 4)
Not enough input arguments.
where line 4 begins with DefaultData = ......................
This is the first time I've tried passing a variable to a cell array within a function.
Any thoughts are greatly appreciated.
Thanks.
0 件のコメント
採用された回答
dpb
2014 年 3 月 12 日
But you didn't pass anything to the function. Invoke as
Test_Message_Body_Builder(BLength)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!