wrong type variable in uitable

function startupFcn(app, set)
app.InstrumTab=LoadInstrum_Struct(set);
app.Setting=set;
app.UITable.Data=app.InstrumTab;
app.UITable.ColumnName=["ProductName";"Ticker";"PointValue";"IntradayMargin";"OvernightMargin";"Slippage(x trade)";"MiniContractTicker";"PointValue1";"IntradayMargin1";"OvernightMargin1";"Slippage1(x trade)";"MicroContractTicker";"PointValue2";"IntradayMargin2";"OvernightMargin2";"Slippage2(x trade)";"Group";"Currency";"ExtraMinUnit"];
app.UITable.ColumnEditable=true;
app.UITable.VariableTypes={'char','char','double','double','double','double','char','double','double','double','double','char','double','double','double','double','char','char','double','logical'};
%questo-...(poi occorre salvarlo)
end
function SaveButtonPushed(app, event)
app.UITableCellSelection();
Instrum_Tab=app.InstrumTab;
disp(Instrum_Tab)
Instrument=string(app.Setting.Instrument);
save(Instrument,'Instrum_Tab');
end
i add data in a table(row 35) and i save it (SaveButtonPushed)
But i see it's a char and not a double (in app.uitable i set :
app.UITable.VariableTypes={'char','char','double','double','double','double','char','double','double','double','double','char','double','double','double','double','char','char','double','logical'};)

6 件のコメント

Matt J
Matt J 2024 年 6 月 1 日
I suggest that you attach app.UITable in a .mat file so we can examine it.
shamal
shamal 2024 年 6 月 1 日
only line 35 was added using the editor and then saved
Matt J
Matt J 2024 年 6 月 1 日
編集済み: Matt J 2024 年 6 月 1 日
The .mat file doesn't contain a uitable object. It is just the table data as a cell array. You need to do,
T=app.UITable;
save filename.mat T
shamal
shamal 2024 年 6 月 1 日
shamal
shamal 2024 年 6 月 1 日
this:
app.UITable.VariableTypes={'char','char','double','double','double','double','char','double','double','double','double','char','double','double','double','double','char','char','double','logical'};
is not correct
i see error
"Unrecognized property 'VariableTypes' for class 'matlab.ui.control.Table'."
VBBV
VBBV 2024 年 6 月 2 日
編集済み: VBBV 2024 年 6 月 2 日
Instrument=app.Setting.Instrument; % try without converting the imported data to string
save(Instrument,'Instrum_Tab');

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2024 年 6 月 1 日

0 投票

"Unrecognized property 'VariableTypes' for class 'matlab.ui.control.Table'."
Indeed, there is no such property. Why did you put it in there? Perhaps you meant to have,
app.UITable.ColumnFormat={'char','char','numeric','numeric','numeric','numeric',...
'char','numeric','numeric','numeric','numeric','char',...
'numeric','numeric','numeric','numeric','char','char','numeric','logical'};

2 件のコメント

shamal
shamal 2024 年 6 月 1 日
yes correct...however I can't convert a 'char' to numeric..I still have the problem
Matt J
Matt J 2024 年 6 月 1 日
編集済み: Matt J 2024 年 6 月 2 日
The screenshot you are showing is a view of Instrum_Tab in the Variable Editor, not in an app uitable. The reason '50' appears as a char vector is because you entered it in the Variable Editor that way, and there is no influence the app has over that.
Presumably you meant to enter it in the UITable.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2024 年 6 月 1 日

編集済み:

2024 年 6 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by