Reading of Slider into text box GUI

1 回表示 (過去 30 日間)
Hassan Bosha
Hassan Bosha 2019 年 2 月 21 日
回答済み: Adam 2019 年 2 月 21 日
I'm displayin a signal
i have two push buttons next and back
i'm diving the signal into 3 blocks on x-axis
from 0 to 4 and from 4 to and from 8 to 12
i want to print 1 in a textbox when x-axis is from 0 to and 2 when it's 4 to 8
This code doesn't show any thing in the textbox
function Btn_Next_Callback(hObject, eventdata, handles)
% hObject handle to Btn_Next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%handles.counter=handles.counter+4;
%set(handles.axes1,'XLim',[handles.counter handles.counter+4]);
% save the updated handles structure
%guidata(hObject, handles);
ax = axis;
x1 = ax(1)+ 4;
x2 = ax(2) + 4;
axis ([x1 x2 ax(3) ax(4)]);
if (x1==0) && (x2==4)
set(handles.edit5,'String' ,'1' );
end
  2 件のコメント
Adam
Adam 2019 年 2 月 21 日
It would only set something in the text box if your x axis minimum is -4.
Hassan Bosha
Hassan Bosha 2019 年 2 月 21 日
how can i make it work through my code ?

サインインしてコメントする。

回答 (1 件)

Adam
Adam 2019 年 2 月 21 日
Something like this would do the job, assuming you on;y want to set the text box value when the axes limits are exactly what you state.
block = [];
if ax(2) - ax(1) = 4
if ax(1) = 0
block = 1;
elseif ax(1) = 4
block = 2;
elseif ax(1) = 8
block = 3;
end
set( handles.edit5,'String' , num2str( block ) );
end

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by