why are my programs treated as function?

5 Ansichten (letzte 30 Tage)
Gabriele Girasole
Gabriele Girasole am 16 Jan. 2023
Beantwortet: Walter Roberson am 17 Jan. 2023
I'd like to apologize for any broken English as it's not my first language. So I was getting started on matlab online, and all the toy problems (manipulation of data inside an array, both 1d and 2d) I was doing were working just fine. Then i tried to implement a program from my professor's slides, which is as follows:
i= 0;
flag = true;
while flag == true
V = [V input('')];
i= i+1;
flag = i< N;
end
The program didn't work, stating that this line:
V = [V input('')];
was the problem. The reason why this doesen't work is lost on me. The error it gives me is the following:
Execution of script provauno as a function is not supported:
/MATLAB Drive/Projects/MATLAB es1/provauno.m
Error in provauno (line 4)
V = [V input('')];
I don't know why it ever began to consider some programs as functions of the one i'm trying to run, but now the other ones i've made thus far don't work either, giving me the error:
Execution of script matrici as a function is not supported:
/MATLAB Drive/Projects/MATLAB es1/matrici.m
Error in provauno (line 4)
I've tried to whipe clean the provauno.m file, so that it would contain only 1 empty line of program, but every other program goes back to giving the error in the 4th line of provauno.m
I am very lost.

Antworten (2)

Constantino Carlos Reyes-Aldasoro
Very very hard to help without the file itself, and without knowledge of what V is. I ran that line in Matlab online and worked well. A suggestion would be to stop the code at that specific line in the editor (hover with your mouse over the line numbers, a red box should appear, then click). When you run the code, the process will be stopped at that specific line, then see what your values of V are. That may give you a clue of what is happening.
If this does not help, you should ask your professor for help as s/he would be the best placed to offer guidance with a specific file written for your classes.

Walter Roberson
Walter Roberson am 17 Jan. 2023
That problem could occur if you have a V.m that invokes your function. You did not initialize V before trying to append to it, so matlab is going to go looking for a function named V

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by