MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by michael Longard on 2 Feb 2013

hi I am new to matlab can you hep me guys Develop my code to show the present result, previous result and total number of result of the number of dots, I've already finish the image processing and show the result, my problem is to show my previous result, and total result. this is my code..

a = get(handles.pres,'String'); %present text string b = get(handles.prev,'String'); %previous text string c = get(handles.total,'String'); %total string

%THIS IS TO SHOW MY PRESENT RESULT set(handles.present,'String',Ndots); %this is to show the present result

%THIS IS TO SHOW MY TOTAL RESULT out = str2num(a) + 0 ; set(handles.total,'String',out); % total result only show by running the program how can I do it to make continues adding result? just like a calculator it stores the previous result i am right?

%THIS IS TO SHOW MY Previous result and i dont have any idea how I am going to pass the string of the present result to the previous string

any help would be appreciate thanks a lot..

*No products are associated with this question.*

Answer by Image Analyst on 2 Feb 2013

You don't need a, b, and c. Just the number of dots and the previous number of dots. First do your calculations to get numberOfDots. Then assign your strings, and then save the current number as the previous number.

labelString1 = sprintf('The previous number of dots = %d', priorNumberOfDots); set(handles.prev, 'String', labelString1); labelString2 = sprintf('The current number of dots = %d', numberOfDots); set(handles.pres, 'String', labelString1); totalNumberOfDots = priorNumberOfDots + numberOfDots labelString3 = sprintf('The total number of dots = %d', totalNumberOfDots); set(handles.total, 'String', labelString1); % Save current number as previous for next time through this code. priorNumberOfDots = numberOfDots; % or totalNumberOfDots, whatever you want.

michael Longard on 3 Feb 2013

Hi Sir Image Analyst I cant get it works =( I want to display the present, previous, total result of the dots detected in my GUI if ever I load a new image to process the GUI, and Its real time so every time the GUI detects another dots he will calculate them?..... this is my code..

originalImage = wa; % wa = the input image or video from snapshot G = rgb2gray(im2double(originalImage)); B = im2bw(imfilter(G, fspecial('gaussian', sigma*3, sigma), 'replicate'), thres); B1 = bwlabel(B); dots = max(B1(:))

%calculate number of dots presentdots = int2str(dots); set(handles.pres, 'String', presentdots);

% and no idea for previous and total number of dots

michael Longard on 3 Feb 2013

Hi Sir any reply? I want to show the results at GUI I am confuse why you started showng the previous result?

Answer by michael Longard on 3 Feb 2013

Hi sir If I detect 1 dot why I am getting 49? if 2 dot I am getting 50 =(

## 0 Comments