Borrar filtros
Borrar filtros

How to run a script on Matlab?

92 visualizaciones (últimos 30 días)
Zulfiqar Khan
Zulfiqar Khan el 25 de Nov. de 2018
Comentada: Walter Roberson el 7 de Mzo. de 2022
Hi,
I can’t run the script. My friend showed me how to run the script but now I am trying alone and its not running instead it pops up profile window. Also some how I have minimized the Menu option window. I want to restore the option window. I have loaded the script and my data file is also inside the workspace.
I have searched the problem on Google but it does not show me the IDE option:
Based upon that I tried the following:
>> run (sample.m)
Undefined variable "sample" or class "sample.m".
>> run(sample);
Attempt to execute SCRIPT sample as a function:
D:\sample.m
The scripts is:
data = closeeye50;
%data = smile50;
titleplot = "closeeye50";
c = data{:,4:8};%4-8 is our actual data; 1 is counter; 2 is ...; search ied counter emotiv epoc
[n,p] = size(data);
t=1:n;
% plot(t,c);%plot of close eye
s=c(1);
fs = 128;%sampling feq from web site
N=length(s);
Some body please guide me
Zulfi.
  3 comentarios
Luis Linares
Luis Linares el 7 de Mzo. de 2022
so, where in hell is answer to his question?
Walter Roberson
Walter Roberson el 7 de Mzo. de 2022
run (sample.m)
In MATLAB, that would attempt to find something named sample on the PATH, with priority given to sample.p or sample.mdl or sample.slx . Having found something named sample, it would attempt to execute it as a function returning one output. If sample turned out to refer to a script then that would result in an error.
If sample turned out to refer to something that was a function, it would execute the function and extract the first output. Then it would attempt to see if the output could be indexed with a field or property named 'm' (the .m part of the syntax.)
run(sample);
In MATLAB, that would attempt to find something named sample on the PATH, with priority given to sample.p or sample.mdl or sample.slx . Having found something named sample, it would attempt to execute it as a function returning one output. If sample turned out to refer to a script then that would result in an error.
If sample turned out to refer to something that was a function, it would execute the function and extract the first output. It would then pass that output to the run function. If the output did not happen to be a character vector or scalar string object, that would result in an error from run()
@madhan ravi and I showed the proper syntaxes below.

Iniciar sesión para comentar.

Respuesta aceptada

madhan ravi
madhan ravi el 25 de Nov. de 2018
Editada: madhan ravi el 25 de Nov. de 2018
just type
sample %in command window and press enter
  4 comentarios
Luis Linares
Luis Linares el 7 de Mzo. de 2022
what does typing sample do?
Steven Lord
Steven Lord el 7 de Mzo. de 2022
If sample is a script file or a function that has a syntax that accepts no input arguments it will execute that script or function. [I'm leaving out a bunch of the other possibilities because in the context of the original question it's most likely either a script or function call.]

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Mobile Fundamentals en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by