Slider UI Control and Callback Function

조회 수: 3 (최근 30일)
johnsmithofmatlab
johnsmithofmatlab 2018년 8월 29일
편집: johnsmithofmatlab 2018년 8월 29일
Hi,
I'm having a few issues with the Slider UIControl on an existing plot. I have managed to show the following:
I don't know how to adapt the Callback function that is provided in the documentation, for my example:
b.Callback = @(es,ed) updateSystem(h,tf(wn^2,[1,2*(es.Value)*wn,wn^2]));
I would like to vary the value of FL along the Slider to automatically update the graph (the lines must stay at the exact same points), and I am expecting the higher the value of FL, the more blue points are generated as described by the criteria labelled in the following code in the comments of this question.
  댓글 수: 1
johnsmithofmatlab
johnsmithofmatlab 2018년 8월 29일
WD = 0.4;
FL = 20;
f=figure;
for FK = [1.25, 1.5, 1.75, 2, 2.5, 3.5, 4, 5, 6];
if FK == 1.25;
y = [2 3 4 5 6 7 8 9 10 20 30 38];
x0 = log10(40);
x1 = log10(10000);
y0 = log10(2);
y1 = log10(38);
elseif FK == 1.5;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60];
x0 = log10(12);
x1 = log10(10000);
y0 = log10(2);
y1 = log10(50);
elseif FK == 1.75;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90];
x0 = log10(5);
x1 = log10(10000);
y0 = log10(2);
y1 = log10(90);
elseif FK == 2;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100];
x0 = log10(3.5);
x1 = log10(8000);
y0 = log10(2);
y1 = log10(100);
elseif FK == 2.5;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100];
x0 = log10(2.5);
x1 = log10(5500);
y0 = log10(2);
y1 = log10(100);
elseif FK == 3.5;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100];
x0 = log10(1.9);
x1 = log10(4200);
y0 = log10(2);
y1 = log10(100);
elseif FK == 4;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100];
x0 = log10(1.7);
x1 = log10(3800);
y0 = log10(2);
y1 = log10(100);
elseif FK == 5;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100];
x0 = log10(1.5);
x1 = log10(2800);
y0 = log10(2);
y1 = log10(100);
elseif FK == 6;
y = [2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100];
x0 = log10(1.2);
x1 = log10(2300);
y0 = log10(2);
y1 = log10(100);
end
x = zeros(1,length(y));
for i = [2:1:max(y)];
y(i) = log10(i);
x(i) = x0 + (((y(i) - y0)/(y1 - y0))*(x1 - x0)); % Linear Interpolation
x(i) = 10^(x(i));
if x(i)*(WD) < FL; % Criteria
loglog(x(i),i,'c.');
elseif x(i)*(WD) > FL;
hold on
loglog(x(i),i,'r.');
xlim([1 10000]);
ylim([1 100]);
end
end
end
grid;
hold on
b = uicontrol('Parent',f,'Style','slider','Position',[81,54,419,23],...
'value',FL, 'min',1, 'max',50);
bgcolor = f.Color;
bl1 = uicontrol('Parent',f,'Style','text','Position',[50,54,23,23],...
'String','1','BackgroundColor',bgcolor);
bl2 = uicontrol('Parent',f,'Style','text','Position',[500,54,23,23],...
'String','50','BackgroundColor',bgcolor);
bl3 = uicontrol('Parent',f,'Style','text','Position',[240,25,100,23],...
'String','FL','BackgroundColor',bgcolor);

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by