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

4 vues (au cours des 30 derniers jours)
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;

Réponse acceptée

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

Plus de réponses (0)




Community Treasure Hunt

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

Start Hunting!

Translated by