Matlab Appdesigner save('xxx.mat') command won't work

  • Thread starter Thread starter mastermechanic
  • Start date Start date
  • Tags Tags
    Matlab Work
Click For Summary
The issue arose when attempting to load and save a matrix in MATLAB App Designer, where the load command returned an empty matrix. The user initialized an empty matrix and successfully saved it, but later, during a button press event, the matrix appeared empty due to a reset section in the code that cleared all variables. After identifying the mistake, the user resolved the problem by removing the reset section, allowing the code to function correctly. This highlights the importance of managing variable states in MATLAB applications. The discussion emphasizes troubleshooting techniques for code execution issues in App Designer.
mastermechanic
Messages
107
Reaction score
15
Homework Statement
It's an Finite Element Method homework to write a code for stresses of the bar and to create a GUI for that.
Relevant Equations
EL = represents Element Matrix but it contains properties of the specific element.
At the start up section I initialize a matrix like:

EL = [ ];
save('EL.mat',"EL");

-------------------------------------------------- This part is okay it creates and saves an empty matrix.

But later, when a button pushed it should record the values of the edit box like:

(This is the section under the app.buttonpushed)

load('EL.mat');
EL = [EL; young_mod length ang];
save('EL.mat', "EL");

---------------------------------------- everything in this buttonpushed section works except this one because when I write load('EL.mat') into command window it returns an empty matrix. I even wrote fprintf('abc'); above load('EL.mat') but it didn't print it.

It made me crazy, it does not read the specific portion of the code and just skips it. I also share the code for you. Please enlighten me.
 

Attachments

  • 1.jpg
    1.jpg
    80.9 KB · Views: 227
Physics news on Phys.org
I found the problem it's a foolish mistake :) I had a reset section between the saving and loading part and it was resetting all the variables. Problem solved.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K