フィルターのクリア

How to get a non integer value from uicomponent slider (Jslider) in Matlab?

1 回表示 (過去 30 日間)
Sunil  Shahi
Sunil Shahi 2013 年 7 月 31 日
I have written this function in Matlab (using a function from the Matlab File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/14583-uicomponent-expands-uicontrol-to-all-java-classes)
function [] = fun()
figure
slider = uicomponent('style','slider', 'position',[50,50,200,45], ...
'value',0.0, 'MajorTickSpacing',2, ...
'MinorTickSpacing',1, 'Paintlabels',1, ...
'PaintTicks',1, 'Orientation',0);
slider.Minimum = -2.05;
slider.Maximum = 2.25;
slider.StateChangedCallback = @myMatlabFunction;
function myMatlabFunction(o,~)
disp(get(o, 'value'))
end
end
When I move the slider, I only get an integer values. I'd like to get floating-point values, e.g., 2.1. How?

回答 (1 件)

Suman Saha
Suman Saha 2013 年 8 月 7 日
function [] = ANALOGCOMM(action) if nargin<1, action='initialize'; end; if strcmp(action,'initialize') close all; figure
sld1Hndl=uicontrol('Style','slider','Tag','sl','Units','inches', ... 'Position',[3 2-0.4 1 0.3],'BackgroundColor',0.6*[0 1 1],'Callback','ANALOGCOMM(''build'')'); uicontrol('Style','text','String','Amplitude','Units','inches','FontName','monotype corsiva', ... 'Position',[3 2 1 0.4],'BackgroundColor',0.3*[0 0 1],'FontSize',15,... 'ForegroundColor',0.9*[1 0 1]); uicontrol('Style','text','Tag','sld','String',' ','Units','inches','FontName','monotype corsiva', ... 'Position',[3 1.1 2 0.4],'BackgroundColor',0.3*[0 0 1],'FontSize',15,... 'ForegroundColor',0.9*[1 0 1]); elseif strcmp(action,'build') VALUE=50; %Change the value & see changes A=VALUE*get(findobj(gcf,'Tag','sl'),'Value'); set(findobj(gcf,'Tag','sld'),'String',sprintf('%f Volt',A));
end
  1 件のコメント
Jan
Jan 2013 年 8 月 7 日
Please explain the relation between this code and the question.

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by