code to pas a value

2 vues (au cours des 30 derniers jours)
Prakash Sharma
Prakash Sharma le 28 Mar 2015
Sir this my code.
mask = bwconvhull(binaryImage);
% Get the masked image
maskedImage = grayImage; % Initialize
maskedImage(~mask) = 0; % Blacken outside skull
% Display the image.
axes(handles.axes2);
imshow(maskedImage,[]);
a=maskedImage;
I am facing an error in the last line: "Undefined function or variable 'a'". So how to fix it so that I assign the value of maskedimage in variable "a" and I also want to pass the value of a using handles structure. How to do it? I am attaching my complete code. Please Sir have look at it.

Réponses (1)

Image Analyst
Image Analyst le 28 Mar 2015
Remember that all variables are local, unless you do special things to make them global, like detailed here: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
So in your SKULL_Callback, you immediately start using the (poorly named) local variable "a" without ever defining it or bringing it in from some other function. Read the FAQ to see how you can access an "a" that you created in some other function, for example by doing this in both functions:
global a;

Community Treasure Hunt

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

Start Hunting!

Translated by