Borrar filtros
Borrar filtros

A simple question about undefined function error

2 visualizaciones (últimos 30 días)
Numan
Numan el 31 de Jul. de 2012
Hello,
Before i ask my question i want to mention that i am beginner level in matlab.
I wrote in matlab a simple program which is given below:
function [ output_args ] = Untitled( input_args )
for i=1:6
for j=1:30
k=1:24;
if 6<=k<17
if ruzgaruretimi(k,j)>sulamagider(k,j)
sebekein==sebekein
elseif ruzgaruretimi(k,j)<sulamagider(k,j)
if sdepo>0
sebekein==sebekein
sdepo==sdepo-1
elseif sdepo==0
sebekein==sebekein+15.708
end
end
end
end
end
end
I defined all veriables but i still get this error message:
Undefined function 'ruzgaruretimi' for input arguments of type 'double'.
Error in dnm (line 6)
if ruzgaruretimi(k,j)>sulamagider(k,j)
How can i solve it?
regards
  1 comentario
Jan
Jan el 31 de Jul. de 2012
Variables are assigned by "=", while "==" compares variables. sebekein==sebekein replies TRUE for all elements - I assume it is meaningless actually.

Iniciar sesión para comentar.

Respuesta aceptada

Daniel Shub
Daniel Shub el 31 de Jul. de 2012
There are so many things wrong with your function that fixing the error you are getting is going to be of little value. If you are a beginner in MATLAB, you need to read the documentation. For example these lines:
k=1:24;
if 6<=k<17
% Do something
end
are not doing what you think they are doing.

Más respuestas (2)

Honglei Chen
Honglei Chen el 31 de Jul. de 2012
You need to make sure that the function ruzgaruretimi are on your path. It should also expect double inputs. If it does, try to do
rehash toolbox
to refresh your toolbox cache.

Wayne King
Wayne King el 31 de Jul. de 2012
Have you defined this variable inside the function? Having the variable in your MATLAB workspace is not sufficient.
You could declare ruzgaruretimi as a global variable, but I think it is probably better to either define it inside your function, or pass that variable to your function as an input argument.
  1 comentario
Wayne King
Wayne King el 31 de Jul. de 2012
Sorry, if it is a function, then what Honglei suggested is correct. I may have misunderstood that ruzgaruretimi is a matrix. If it is a matrix, then you have to make it a global variable, define it inside the function, or pass it as an input argument.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by