Azzera filtri
Azzera filtri

Error in a line

6 visualizzazioni (ultimi 30 giorni)
Igina
Igina il 21 Giu 2013
Hi everybody, I'm creating a new function but I have problems with the following code:
function I= ind(passo, MATRICE, stato, numero_simulazione)
if MATRICE(numero_simulazione, passo)==stato
I=1;
else
I=0;
end
end
Could you help me please? Thank you
  4 Commenti
Walter Roberson
Walter Roberson il 21 Giu 2013
Did it tell you that function definitions were not permitted in that context? Did it tell you that array indices must be non-positive integers? Did it tell you that an input argument was not defined?
Igina
Igina il 21 Giu 2013
I have matlab only at university so I can't not tell exactly what it tells me but it was more or less "error in line 2" in this function. If there had been something more I would have posted it in the first post for sure. I' sorry and I really can't figure out what the problem is.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 21 Giu 2013
In order to run that function, you must start it from the MATLAB command line, and you must provide all the relevant arguments in that command. For example,
ACAD>> ind(5, floor(10*rand(15,17)), 2, 11)
You cannot start this function by just pressing F5 or clicking "Run" in the menus.
  1 Commento
Igina
Igina il 22 Giu 2013
Thank youfor the answer. I just used this function in another file called "potential.m" and wrote in the relevant arguments (which are known in "potential") and wrote in the command line "potential". What's wrong?

Accedi per commentare.

Categorie

Scopri di più su Parallel Computing in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by