필터 지우기
필터 지우기

How do I pass a variable into a function containing a cell array?

조회 수: 1 (최근 30일)
Brad
Brad 2014년 3월 12일
댓글: Brad 2014년 3월 12일
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)
  댓글 수: 1
Brad
Brad 2014년 3월 12일
Dang, it had to be something simple!!
Thanks for taking a look!

댓글을 달려면 로그인하십시오.

추가 답변 (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