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

10 views (last 30 days)
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;

Accepted Answer

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

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!