A code is not working with editor window but works in command window for me
Show older comments
Hello. I made a GUI to read an image of size 320*240 and normalize it to range 0 - 1. Followed by it when the user clicks or selects a pixel of the normalized image, the pixel value is saved to a variable. This value is checked with a column matrix and when same value is found in it corresponding position (say ‘m’) is obtained. Then the value in array 2, in the same position (m) is displayed in a static text box.All this is done when the user clicks on a push button. The following code doesn’t work with editor window but works in command window. I tried using ‘set’ code line within and outside the loop. I don’t know what is the problem behind this, kindly help me. Thank you and Good day.
rggb=0.5113; % pixel value selected by user from normalized image
q=linspace(0,1,20001); % array 1
w=linspace(17,37,20001); % array 2
for m=1:20001 % possible positions
if q(m)==rggb % Compare if ‘m’th value in array 1 matches with rggb
m; % corresponding ‘m’ where ‘rggb’ matches in array 1
w(m); % corresponding ‘m’ value in array 2
set(handles.text1,’String’,num2str(w(m)); % display ‘m’th array 2 value as string in static text box
end % end for the if loop
end % end for the for loop

Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!