Modified but still get errors. Is it more clear to help me?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I just modified the code I am trying to use in order to select one out of two images. I use that code
MyMatrix = Img;
setappdata(gcf, 'MyMatrix', MyMatrix);
handles.axes1 = subplot(1,2,1);
handles.axes2 = subplot(1,2,2);
axes(handles.axes1)
handles.r1 = uicontrol('Style',...
'radiobutton',...
'String','Option 1',...
'Position',[10 350 100 30],...
'Value',croppedImage,'Callback',@XRadiobuttonCallback);
axes(handles.axes2)
handles.r2 = uicontrol('Style','radiobutton',...
'String','Option 2',...
'Position',[10 250 100 30],...
'Value',J,'Callback',@XRadiobuttonCallback);
guidata(gcf,handles);
And at the end of the script I use the Callback fcn
function XRadiobuttonCallback(~,~)
handles = guidata(gcf);
%// Here retrieve MyMatrix using getappdata.
MyMatrix = getappdata(gcf, 'MyMatrix');
idx = round((get(handles.r1, 'Value')));
idx2 = round((get(handles.r2, 'Value')));
set(handles.Edit1,'String',num2str(idx));
set(handles.r1,'Value',idx);
set(handles.r2,'Value',idx2);
subplot(1,2,1)
image(handles.axes1, croppedImage(:,:,idx))
imshow(squeeze(croppedImage(:,:,idx,:)))
subplot(1,2,2)
image(handles.axes2, J(:,:,idx2));
imshow(squeeze(J(:,:,idx2,:)),'XData',[1 592], 'YData',[1 481])
guidata(gcf,handles);
drawnow()
end
But I still get the error
Error using uicontrol
This is not a valid UIControlValue value. The input must have 1 rows.
Error in ruller (line 136)
handles.r1 = uicontrol('Style',...
>>
What is this error? Can you help me please?
0 commentaires
Réponses (1)
Geoff Hayes
le 11 Fév 2019
Stelios - please look at this code
handles.r1 = uicontrol('Style',...
'radiobutton',...
'String','Option 1',...
'Position',[10 350 100 30],...
'Value',croppedImage,'Callback',@XRadiobuttonCallback);
Why are you setting the Value to be a cropped image (if that is what croppedImage is)? Wouldn't Value be 0 or 1 for the button to be toggled off or on respectively? I think that those two value are the only appropriate ones for this property...
1 commentaire
Walter Roberson
le 11 Fév 2019
The Value associated with a uicontrol style 'radiobutton' or 'pushbutton' or 'togglebutton' or 'checkbox' must be empty or equal to either the 'Min' or 'Max' property of the uicontrol. Value equal to the 'Min' indicates that the button is not (currently) pushed or selected; Value equal to the 'Max' indicates that the button is currently pushed or selected.
The Value associated with a uicontrol style 'listbox' or 'popupmenu' must be empty or an integer from 1 to the number of entries in the uicontrol 'String' property.
The Value associated with a uicontrol style 'slider' must be between the 'Min' and 'Max' property of the uicontrol and indicates the location of the slider within the range.
The Value associated with a uicontrol style 'edit' can be fairly arbitrary, but if the value is <= 1 then the edit box will only support one line of input, and value > 1 then the edit box will support multiple lines of input.
The Value associated with a uicontrol style 'text' or 'frame' has no meaning.
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!