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
SUMMARY

The issue discussed revolves around the use of the `save` and `load` commands in MATLAB App Designer. Initially, an empty matrix `EL` is saved successfully using `save('EL.mat', "EL")`. However, when attempting to load and append data to `EL` upon a button press, the matrix appears empty due to a reset section in the code that clears all variables. The problem was resolved by removing the reset section, allowing the data to be retained and manipulated correctly.

PREREQUISITES
  • Familiarity with MATLAB App Designer
  • Understanding of MATLAB matrix operations
  • Knowledge of the `save` and `load` functions in MATLAB
  • Basic debugging techniques in MATLAB
NEXT STEPS
  • Review MATLAB App Designer documentation for state management
  • Learn about MATLAB variable scope and persistence
  • Explore debugging techniques in MATLAB to identify variable states
  • Investigate best practices for data storage in MATLAB applications
USEFUL FOR

This discussion is beneficial for MATLAB developers, particularly those working with App Designer, who need to manage data persistence and troubleshoot variable handling in their applications.

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: 229
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
2
Views
2K
Replies
6
Views
3K
Replies
1
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K