필터 지우기
필터 지우기

??? Undefined function or method 'sliderK_Callback'

조회 수: 1 (최근 30일)
Guillermo Lopez
Guillermo Lopez 2012년 2월 2일
편집: Matt J 2013년 9월 26일
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

채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 2일
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
Guillermo Lopez
Guillermo Lopez 2012년 2월 2일
and where do I need to define it? In the same place as sliderD?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by