How do I pass a variable into a function containing a cell array?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
dpb
on 12 Mar 2014
But you didn't pass anything to the function. Invoke as
Test_Message_Body_Builder(BLength)
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!