Clear Filters
Clear Filters

??? Undefined function or method 'sliderK_Callback'

1 view (last 30 days)
I am getting the error: ???
Undefined function or method 'sliderK_Callback' for input arguments of type 'double'.
Error in ==> Slider_nFlake at 28 sliderK_Callback(0,0);
The code is as follows:
function Slider_nFlake
%%Crea la figura
figura1 = figure ;
%%Create axes
graph = axes('LineWidth',1.5,'Position',[0.15 0.10 0.65 0.65]);
%%Create controls
% Sliders
sliderD = uicontrol('Style', 'slider', 'String', 'thickness',...
'Position', [20 370 200 20],'Callback',{@sliderD_Callback},...
'Min',1,'Max',10,'SliderStep',[0.001 0.001],'Value',3.0);
SliderDtext= uicontrol('Style', 'text','position',[20 350 200 20],'string','nFlakeRe');
textD = uicontrol('Style','text','Position', [20 390 100 20]);
sliderK = uicontrol('Style', 'slider', 'String', 'thickness',...
'Position', [230 370 200 20],'Callback',{@sliderK_Callback},...
'Min',0,'Max',10,'SliderStep',[0.001 0.001],'Value',0.0);
SliderKtext= uicontrol('Style', 'text','position',[230 350 200 20],'string','nFlakeIm');
textK = uicontrol('Style','text','Position', [230 390 100 20]);
sliderD_Callback(0,0);
sliderK_Callback(0,0);
% update slider value
%%Callback
function sliderD_Callback(source,eventdata)
D = get(sliderD,'Value');
set(textD,'String',D) ;
K = get(sliderK,'Value');
set(textK,'String',K) ;
[dd,cc]=contrast2(D,K) ;
hold off ;
plot(dd,cc) ;
end
end
Please could you actually tell me what Im doing wrong? I am trying to have a slider that when changed, gives the values to two variables D and K and put them into a function which I have in a different .m document:
function [dd,cc]=contrast2(nflakere,nflakeim)
lambda0=500;
nair=1;
nflake=nflakere+1i*nflakeim;
nSi=2+1i*0.06
dSiO2=285;
%loop
i=1;
for dflake=0:0.1:35
mSiO2=Sij(nair,nSiO2(lambda0))*Pj(nSiO2(lambda0),dSiO2,lambda0)*Sij(nSiO2(lambda0),nSi);
mflake= Sij(nair,nflake)*Pj(nflake,dflake,lambda0)...
*Sij(nflake,nSiO2(lambda0))*Pj(nSiO2(lambda0),dSiO2,lambda0)*Sij(nSiO2(lambda0),nSi);
%bare silicon oxide reflection coefficient
rSiO2=abs(mSiO2(2,1)/mSiO2(1,1))^2;
%flake reflection coefficient
rflake=abs(mflake(2,1)/mflake(1,1))^2;
%Contrast
C(i)=(rflake-rSiO2)/(rflake+rSiO2);
dflake2(i)=dflake;
i=i+1;
dd=dflake2;
cc=C;
end
As you can see dd and cc are the two variables I'm using in the slider_nflake.m and the D and K values obtained are used to obtain nFlake which consists of a nFlakeRe and nFlakeIm part (those values I would like to obtain when changing the slider). Please could someone help me!!! Thanks in advance

Accepted Answer

Walter Roberson
Walter Roberson on 2 Feb 2012
Your code shows you defining a nested function sliderD_Callback but there is no definition shown for any function sliderK_Callback, which you reference twice in your code.
  1 Comment
Guillermo Lopez
Guillermo Lopez on 2 Feb 2012
and where do I need to define it? In the same place as sliderD?

Sign in to comment.

More Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!