How can i call exact cell value from excel to edit field value in Matlab App

9 次查看(过去 30 天)
I am trying to import and excel file which has inputs in some cells and then trying to assign it to Editfiled in matlab app so i can do simple calculation.
All i want it to do is take the value from a particular Excel cell and then assign it to this.
% Button pushed function: Button
function ButtonPushed(app, event)
[file,filepath] =uigetfile({'*.xlsx*'},'Select the Excel file');
filename =fullfile(filepath,file);
t= readcell(filename,'Sheet','Input','Range','A2:B34');
app.MassEditField.Value = t(2,"Var2");
app.ForceEditField.Value =t(13,"Var2");
app.m = app.MassEditField.Value;
app.g= app.ForceEditField.Value;
app.Result = app.m * app.g;

采纳的回答

Voss
Voss 2023-5-2
Use curly braces {} to get content from the table t:
app.MassEditField.Value = t{2,"Var2"};
app.ForceEditField.Value =t{13,"Var2"};

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by