How to take multiple input using Edit Field (Text), MATLAB app designer?
Mostrar comentarios más antiguos
I have 25 images (numbered 1 to 25) as output from which I want the user to select the ones that is needed to be manually edited by entering the number of the image, like 1, 2, 15, 21 using Edit Field (Text) in MATLAB app designer.
In the simple coding format I did the following,
answer = questdlg('Do you want to adjust outline manually','Manual outline','Yes','No','No');
switch answer
case 'Yes'
prompt = {'Enter well number to adjust:'};
dlgtitle = 'Well number';
dims = [1 50];
definput = {'1,5,8,etc.'};
well_pos = inputdlg(prompt,dlgtitle,dims,definput);
[output_BF_new, para_BF_new] = manual_adjust(Well, well_pos, output_BF,para_BF);
figure, montage(output_BF_new)
case 'No'
disp('Image analysis complete')
para_BF_new = para_BF; output_BF_new = output_BF;
end
--------------------------------------------------------------------------------------------------------------------
However, in case of MATLAb app designer when I do the following,
function ManualButtonPushed(app, event)
%app.well_pos = app.WellPositionEditField.Value{1};
%app.well_pos(~isstrprop(app.well_pos,'digit')) = ' '; %replace non-numeric characters with empty space
%vec = str2double(strsplit(strtrim(str))); % trim white space and convert to numeric
app.well_pos = str2num(app.WellPositionEditField.Value{1});
%app.well_pos = str2double(strsplit(app.WellPositionEditField.Value(1)));
[output_BF_new, para_BF_new] = manual_adjust(app.Well, app.well_pos, app.output_BF, app.para_BF);
%figure, montage(output_BF_new)
montage(app.output_BF_new, 'Parent', app.UIAxes_2)
axis(app.UIAxes_2, 'tight');
end
The following error is generated:
Brace index is not supported for variables of this type.
--------------------------------------------------------------------------------------------------------------------
The code for the function is:
function [array, param] = manual_adjust(Well, well_pos, array, param)
mod_pos = str2num(well_pos{1});
for b=1:length(mod_pos)
image = Well{mod_pos(b)};
black = logical(zeros(size(image)));
%figure,imshow(image);
[myobj,xs,ys] = freehanddraw(gca,'color','r','linewidth',2);
boundary = [uint8(ys), uint8(xs)];
Par = blob_parameters(xs, ys);
param(mod_pos(b),1:5) = Par;
BW8 = select_bound(black, boundary);
BW8f = imfill(BW8,'holes');
intensity = regionprops(BW8f, image, 'MeanIntensity');
param(mod_pos(b),6) = intensity.MeanIntensity;
BWoutline3 = bwperim(BW8f);
array{mod_pos(b)} = imoverlay(image,BWoutline3,'red');
end
4 comentarios
Rik
el 8 de Mzo. de 2023
Where exactly is the error generated? Does that happen in the external function or in the callback itself?
Based on the number of different approaches in your commented code, you seem to have some trouble extracting a numeric value from your edit field.
Amlan basu
el 8 de Mzo. de 2023
Rik
el 8 de Mzo. de 2023
Before doing multiple operations in a single line, first you must find out what the class, size, and contents of your variable are. So what do these lines return?
Val=app.WellPositionEditField.Value;
class(Val),size(Val),disp(Val)
Amlan basu
el 8 de Mzo. de 2023
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Type Identification en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!