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!