Error: Undefined function 'colon' for input arguments of type 'matlab.ui​.control.N​umericEdit​Field'.

16 views (last 30 days)
Hi, i'm getting this error in a line where i'm just trying to create a vector and i have no idea why.
function ConvolucionButtonPushed(app, event)
% Comienzo de la convolucion
a = app.PuntodeinicioXEditField; % Limite inferior de X
b = app.PuntodefinXEditField; % Limite superior de X
c = app.PuntodeinicioHEditField; % Limite inferior de H
d = app.PuntodefinHEditField; % Limite superior de H
r = 0.01; % Resolucion
t = a:r:b; % Vector tiempo para X (HERE IS WHERE THE ERROR APPEARS)
t2 = c:r:d; % Vector tiempo para H
ty = a+c:r:b+d; % Vector tiempo para Y
N = length(t); % Longitud de X
M = length(t2); % Longitud de H
Ny = N+M-1; % Longitud de Y
% Armar la funcion X
Ax = app.AmplituddeXEditField.Value;
Pix = app.PuntodeinicioXEditField.Value;
Pfx = app.PuntodefinXEditField.Value;
Ex = app.ExponenteXEditField.Value;
tx = Pix:0.01:Pfx;
x = Ax*exp(Ex*tx);
% Armar la funcion H
Ah = app.AmplituddeHEditField.Value;
Pih = app.PuntodeinicioHEditField.Value;
Pfh = app.PuntodefinHEditField.Value;
Eh = app.ExponenteHEditField.Value;
th = Pih:0.01:Pfh;
h = Ah*exp(Eh*th);
% Convolucion
y = zeros(1,Ny);
for i = 1:N
for k = 1:M
y(i+k-1) = y(i+k-1) + h(k)*x(i);
end
end
% Plot
plot(app.UIAxes,ty,y,"Color",[0.8500, 0.3250, 0.0980])

Answers (1)

Steven Lord
Steven Lord on 31 Mar 2021
You don't want to use the handle to the graphics object in your expression to create a vector using the : operator. You want to use the value of the Value property of that graphics object instead. It's the difference between giving someone who asks for your friend's phone number your phone (using the object) or reading off the number stored in your phone (using the Value of the object.)
a1 = app.PuntodeinicioXEditField % Gets the handle of the object
a2 = app.PuntodeinicioXEditField.Value % Gets the value of the edit field

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!