[問題] GUI-Y捲軸不會動已回收
各位板上的大大晚安...
小弟最近練習寫一個雙捲軸的的GUI但是Y軸卡住了,我大致知道問題出在哪邊,
但是不知如何修改比較恰當,煩請高手指導一下小弟!感謝!
下面是我的程式碼,我有將我認為可能出問題的地方Mark起來。
clear all;
close all;
clc;
%=========Variable=========
% set the X and Y axies display range
Xaxis_width=1.5;
Yaxis_high=0.5;
%=========Plot formula=====
x=linspace(0,2*pi,300);
y=sin(x);
%=========Plot=============
fig1=figure('Menubar','none');
plot(x,y,'--rs','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor',...
'r','MarkerSize',5);
title('Implement the slider function in plot the sin wave');
ylabel('sin(\theta)');
xlabel('sample point');
%========slider setup=====
set(gca,'xlim',[0 Xaxis_width],'ylim',[0 Yaxis_high]);
axis_pos=get(gca,'position');
%=======Yaxis============
slider_Ypos=[axis_pos(1)-0.08,axis_pos(2),0.02,axis_pos(4)];
%Set Y slider position
Yaxis_callback_fcn=['set(gca,''ylim'',...
get(gcbo,''value'')+[' num2str(Yaxis_high) ' 0 ])'];
因為Y的範圍是-1到1,所以這一段我不知道應該要怎麼寫比較恰當
另外為什麼是num2str而不是str2num?
能做四則運算的不應該都是數字嗎?
Yslider_h=uicontrol('style','slider','units','normalized','position',...
slider_Ypos,'callback',Yaxis_callback_fcn,'max',max(y));
%========Xaxis============
slider_Xpos=[axis_pos(1),axis_pos(2)-0.08,axis_pos(3),0.03];%Set X slider position
Xaxis_callback_fcn=['set(gca,''xlim'',get(gcbo,''value'')+[0 ' num2str(Xaxis_width) '])'];
Xslider_h=uicontrol('style','slider','units','normalized','position',slider_Xpos,'callback',Xaxis_callback_fcn,'max',max(x));
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.230.232.38
※ 編輯: yimean 來自: 61.230.222.155 (10/30 21:50)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章