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.

采纳的回答

dpb
dpb 2014-3-12
But you didn't pass anything to the function. Invoke as
Test_Message_Body_Builder(BLength)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by