フィルターのクリア

ok button gives error:Subscript indices must either be real positive integers or logicals. Error using waitfor Error while evaluating uicontrol Callback

1 回表示 (過去 30 日間)
oshin
oshin 2014 年 2 月 24 日
コメント済み: oshin 2014 年 2 月 24 日
Thank you for the help. I have already corrected that mistake. The main issue is that if I am running the code as a standalone code it is running successfully but if the gui and database are connected with the same code, then this type of error is occuring:
"Subscript indices must either be real positive integers or logicals.
Error using waitfor Error while evaluating uicontrol Callback"
and after the error,if the same code ie without gui and database is executed,it continuously gives the same error again and again.

回答 (1 件)

Iain
Iain 2014 年 2 月 24 日
That error is because, somewhere in your code you've got something like
number = -1;
array(0) or array(1.4) or array(23,0) or array(number)
somewhere in your code.
  1 件のコメント
oshin
oshin 2014 年 2 月 24 日
The code is given below:
%start.m f1=figure('numbertitle','off','name','Sputum cytology','position',[0 20 1500 800]); set(f1,'menubar','none') imshow('C:\Users\hp\Desktop\projcode\bk.jpg') proc=uicontrol('position',[250 100 100 50],'callback','close(f1),shell1','string','PROCESS','fontsize',10); add=uicontrol('position',[450 100 100 50],'callback','close(f1),adf','string','ADD SAMPLE','fontsize',10);
delete=uicontrol('position',[650 100 100 50],'callback','close(f1),delf','string','DELETE','fontsize',10); shw=uicontrol('position',[850 100 100 50],'callback','close(f1), loginf','string','SHOW','fontsize',10);
%shell1.m
dlg_title = 'Input'; num_lines = 1; prompt = {'re-enter opd:'}; % label for each input %def = {'10','20'}; % default values of each input answer = inputdlg(prompt, dlg_title, num_lines); % open dialog box
if ~isempty(answer) % only if OK button was clicked op = str2double(answer{1}); % f = str2double(answer{2}); end dbpath = ('C:\Users\hp\Desktop\projcode\fsputumcyto.accdb'); url = [('jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ=') dbpath]; con = database('','','','sun.jdbc.odbc.JdbcOdbcDriver', url);
sql_q=strcat('SELECT result FROM Result WHERE opd=',num2str(op)); curs = exec(con,sql_q); curs = fetch(curs); r=curs.Data; disp(r); cm=strcmp(r,'No Data'); if cm==0 %h=errordlg('Record exist Check OPD No.','Incorrect OPD'); %uiwait(h); %f = figure; %h = uicontrol('Position',[20 20 20 40],'String','ok',... % 'Callback','uiresume(gcbf)'); h = sprintf('Record exist Check OPD No. \n Incorrect OPD'); uiwait(msgbox(h)); %waitforbuttonpress;
f1=figure('numbertitle','off','name','Sputum cytology','position',[0 20 1500 800]);
set(f1,'menubar','none')
imshow('C:\Users\hp\Desktop\projcode\bk.jpg')
res=uicontrol('position',[500 250 100 50],'callback','close(f1),shell','string','Re-run','fontsize',10);
else
[p q]=uigetfile(strcat(num2str(op),'.jpg'),'C:\Users\hp\Desktop\projcode'); qp=strcat(q,p); chk=strcmp(p,num2str(op)); if chk==0 pic = imread(qp); %pic = imread('E:\sputum samples\IMG_0832.jpg'); width = 700; dim = size(pic); hsvimg = imresize(pic,[width*dim(1)/dim(2) width],'bicubic'); % hsvimg = rgb2n(pic2);
srgb2lab = makecform('srgb2lab'); lab2srgb = makecform('lab2srgb');
shadow_lab = applycform(hsvimg, srgb2lab); % convert to L*a*b*
% the values of luminosity can span a range from 0 to 100; scale them % to [0 1] range (appropriate for MATLAB® intensity images of class double) % before applying the three contrast enhancement techniques max_luminosity = 1; L = shadow_lab(:,:,1)/max_luminosity;
% replace the luminosity layer with the processed data and then convert % the image back to the RGB colorspace shadow_imadjust = shadow_lab; shadow_imadjust(:,:,1) = imadjust(L)*max_luminosity; shadow_imadjust = applycform(shadow_imadjust, lab2srgb);
f1=figure('numbertitle','off','name','Sputum cytology','position',[0 20 1500 800]); set(f1,'menubar','none') if(~isdeployed) cd(fileparts(which(mfilename))); end
imtool close all; % Close all figure windows created by imtool. workspace; % Make sure the workspace panel is showing. fontSize = 16; % Read in standard MATLAB gray scale demo image. grayImage = shadow_imadjust; %imread('C:\Users\hp\Desktop\mat\sputum samples\col.jpg'); gi=rgb2gray(grayImage); subplot(2, 3, 1); imshow(grayImage, []); title('Enhanced Image', 'FontSize', fontSize); %set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
%f = figure; %h = uicontrol('Position',[20 20 20 40],'String','ok',... % 'Callback','uiresume(gcbf)');
message = sprintf('Left click and hold to begin drawing.\nSimply lift the mouse button to finish');
uiwait(msgbox(message)); %waitforbuttonpress; hFH = imfreehand(); % Create a binary image ("mask") from the ROI object. binaryImage = hFH.createMask(); % Display the freehand mask. bi=~binaryImage; subplot(2, 3, 2); imshow(binaryImage); title('Binary mask of the region', 'FontSize', fontSize); % Calculate the area, in pixels, that they drew. n1 = sum(binaryImage(:)) % Another way to calculate it that takes fractional pixels into account. n2 = bwarea(binaryImage) % Get coordinates of the boundary of the freehand drawn region. structBoundaries = bwboundaries(binaryImage); xy=structBoundaries{1}; % Get n by 2 array of x,y coordinates. x = xy(:, 2); % Columns. y = xy(:, 1); % Rows. subplot(2, 3, 2); % Plot over original image. hold on; % Don't blow away the image. plot(x, y, 'LineWidth', 2); drawnow; % Force it to draw immediately. %Burn line into image by setting it to 255 wherever the mask is true. burnedImage = grayImage; burnedImage(binaryImage) = 255; %Display the image with the mask "burned in." subplot(2, 3, 3); imshow(burnedImage); caption = sprintf('New image with\nmask burned into image'); title(caption, 'FontSize', fontSize); end end
try to run the execute only the "process" tab as the error occurs in the shell1 code only.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by