MATLAB Answers

variables values not updating in workspace

45 views (last 30 days)
giacomo
giacomo on 22 Nov 2017
Edited: giacomo on 22 Nov 2017
Hi everyone. I've been working on a code and just lately realized this weird behaviour from the script. I was always measuring a diameter of a cropped image using imshow and ginput(2), today I changed to imtool, and I noticed that using imtool was actually changing the values of 'diameter' variable, while when using imshow it wasn't. Same thing happens with the cropped image ('Crop') size!
For example, if I run my code twice using imshow and ginput(2) I get:
  1. First run: cropped image dimensions -> [200 100 3] and diameter -> 24
  2. Second run: cropped image dimensions (this time with very different size on purpose) -> [200 100 3] and diameter (again different) -> 24
Later on I launch a GUI 'guiprova' in the script and while the updated results from 'guiprova' are stored in a m.mat file, their values are updated just when I run the script another time, so all the code after launching the GUI interface becomes inconsistent!
For example:
  • Run the code, go to GUI interface and get the variables values -> variables values are stored before ending the GUI interface and are those from the previous code run
How can I solve these two problems? I know they are distinct but somehow both related to 'updating variable value' problems. I'll attach the code. Thanks!

  4 Comments

Show 1 older comment
giacomo
giacomo on 22 Nov 2017
I attached the GUI interface. The m.mat file would ideally be created in the GUI file and would save the variables to the workspace each time I run virtualnetcolori.m so I can do further operations with them. Instead, the virtualnetcolori.m goes on until the end not taking into account what I'm trying to do in the GUI (updating 4 variables). In the best case it returns me the m.mat file from the previous run.
To prevent this I even try to type delete('m.mat') in the OpeningFcn of the GUI so that the previously stored values that keep popping up are deleted everytime I run the code, but it's not working, it's like the virtualnetcolori.m reads all of that code before I can even input the mat file in the GUI interface. I can't find anything online for now.
Image Analyst
Image Analyst on 22 Nov 2017
What GUI? I see no fig file, just some m-files.
giacomo
giacomo on 22 Nov 2017
Attached that too now.
EDIT: I finally found something that suits my problem.
I'll test it a bit and come back if I have some issues.

Sign in to comment.

Answers (0)

Sign in to answer this question.