problem insert data in uitable (app designer)

function [T1,nome]=Carico_i_nomiFile_e_Dati_Folder_Struct(g)
if g==1
[file2,~] = uigetfile('c:\Titan\reports\*.txt', 'Select a file');%,'MultiSelect','on'); %%da sistemare!class(TF
if ~isempty(file2)
T1=file2;
T1=[T1,{0},{"CL"},{"As Is"},{'008/01/01'},{"From Instrument"},{"0"},{"Trend"},{"Multiday"},{"No"},{"1"},{"0"},{"0"},{"0"},{"0"}]
end
end
T1=Carico_i_nomiFile_e_Dati_Folder_Struct(1);
r=0;
if ~isempty(T1)
%nr=[T1,"On","Underlying","Trading","OOS","Sipp.source","Slippage","Type","Horizon","Filter skip","Static Size","Min Size","Max Size","Min AvgTrade","Select"]
% nr=[T1,{"0"},{"CL"},{"As Is"},{"2008/01/01"},{"From Instrument"},{"0"},{"Trend"},{"Multiday"},{"No"},{"1"},{"0"},{"0"},{"0"},{"0"}]
T1
app.UITable.Data=[T1];
end
T1 =
1×15 cell array
Columns 1 through 7
{'CL_T-Live 2022 …'} {[0]} {["CL"]} {["As Is"]} {'008/01/01'} {["From Instrument"]} {["0"]}
Columns 8 through 15
{["Trend"]} {["Multiday"]} {["No"]} {["1"]} {["0"]} {["0"]} {["0"]} {["0"]}
Error setting property 'Data' of class 'Table':
Values within a cell array must be numeric, logical, or char
Error in PredatorManageStrategie/AddStrategiesButtonValueChanged (line 79)
app.UITable.Data=[T1];
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating StateButton PrivateValueChangedFcn.

 Accepted Answer

Replace all the double-quotes in this:
T1=[T1,{0},{"CL"},{"As Is"},{'008/01/01'},{"From Instrument"},{"0"},{"Trend"},{"Multiday"},{"No"},{"1"},{"0"},{"0"},{"0"},{"0"}]
with single-quotes, like this:
T1=[T1,{0},{'CL'},{'As Is'},{'008/01/01'},{'From Instrument'},{'0'},{'Trend'},{'Multiday'},{'No'},{'1'},{'0'},{'0'},{'0'},{'0'}]
Single-quotes define character vectors; double-quotes define strings. Apparently uitable doesn't like strings, but character vectors are ok.

5 Comments

By the way, you can avoid all those extra curly braces too:
T1={T1,0,'CL','As Is','008/01/01','From Instrument','0','Trend','Multiday','No','1','0','0','0','0'}
shamal
shamal on 18 Jul 2023
Moved: Voss on 18 Jul 2023
thanks..
Another questions:
if i want to use multiple select file :
file2 =
1×6 cell array
Columns 1 through 4
{'CL_T-Live 2022 …'} {'EQ_T-Live 2022 …'} {AB_T-Live 2022 …'}
how can i attach file2 to
['CL','As Is','008/01/01','From instrument','0','Trend','Multiday','No','1','0','0','0','0'}
(the string is egual in all element of file2 )
i want this:
['CL_T-Live 2022 …','CL','As Is','008/01/01','From instrument','0','Trend','Multiday','No','1','0','0','0','0'}
[EQ_T-Live 2022 …'},'As Is','008/01/01','From instrument','0','Trend','Multiday','No','1','0','0','0','0'}
..
i try it but there is error here
D1{:,2}=ud{:} ===> error
D1{:,1}=T1{:} ===> error
[file2,~] = uigetfile('c:\Titan\reports\*.txt', 'Select a file','MultiSelect','on'); %%da sistemare!class(TF
if ~isempty(file2)
T1=string(file2);
T2=[1,{''},{'As Is'},{'2008/01/01'},{'From Instrument'},{0},{'Trend'},{'Multiday'},{'No'},{1},{0},{0},{0},{0}]
D1=repmat(T2,width(T1),1);
ud=extractBefore(T1,"_");
D1{:,2}=ud{:} ===> error
D1{:,1}=T1{:} ===> error
end
[file2,~] = uigetfile('c:\Titan\reports\*.txt', 'Select a file','MultiSelect','on'); %%da sistemare!class(TF
if isnumeric(file2)
return
end
if ~iscell(file2)
file2 = {file2};
end
other_columns = {'As Is','2008/01/01','From Instrument',0,'Trend','Multiday','No',1,0,0,0,0};
app.UITable.Data = [file2(:) extractBefore(file2(:),'_') repmat(other_columns,numel(file2),1)];
very good..thanks

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Asked:

on 18 Jul 2023

Commented:

on 19 Jul 2023

Community Treasure Hunt

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

Start Hunting!