Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Share variables between two popup menu? please help.
1 回表示 (過去 30 日間)
古いコメントを表示
i have a question please help me? i have two popup menu, i share a variables between them but in one of them popup menu a variable doesn't declare, how can declare a variable that can use between them? completely i mean how can declare variable X and use between them ? ---------------
function popupmenu1_Callback(hObject, eventdata, handles)
str=get(hObject,'String');
val=get(hObject,'Value');
RGBimage=imread('C:\Users\Best Technology\Pictures\Camera Roll\WIN_20141029_092813.jpg');
[height,width,depth]=size(RGBimage);
switch str{val} ;
case 'Load'
axes(handles.axes1);
i=imread('C:\Users\Best Technology\Pictures\Camera Roll\WIN_20141029_092813.jpg');
imshow(i);
case 'Red'
axes(handles.axes2);
outputimage=uint8(zeros(height,width,depth));
for w=1:width
for h=1:height
outputimage(h,w,x)=RGBimage(h,w,x);
end
end
image(outputimage);
case 'Green'
axes(handles.axes2);
outputimage=uint8(zeros(height,width,depth));
for w=1:width
for h=1:height
outputimage(h,w,x)=RGBimage(h,w,x);
end
end
image(outputimage);
case 'Blue'
axes(handles.axes2);
outputimage=uint8(zeros(height,width,depth));
for w=1:width
for h=1:height
outputimage(h,w,x)=RGBimage(h,w,x);
end
end
image(outputimage);
end
--------------------
function popupmenu2_Callback(hObject, eventdata, handles)
str=get(hObject,'String');
val=get(hObject,'Value');
switch str{val} ;
case 'One'
x=1;
case 'Two'
x=2;
case 'Three'
x=3;
end
0 件のコメント
回答 (1 件)
Jason Moore
2015 年 2 月 6 日
Without knowing your code structure it is hard to give you the best answer possible. But an option that would work could be to use assignin and eval. assignin will take a value and assign it to the specified value in the specified workspace. eval will run a given command in the specified workspace.
Example
%write a value of 1 to x in the base workspace
assignin('base','x',1)
%read the value of x that is stored in the base workspace
val = eval('base','x')
By using this method the data will be viewable in your base workspace.
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!