Effacer les filtres
Effacer les filtres

How to run a script on Matlab?

92 vues (au cours des 30 derniers jours)
Zulfiqar Khan
Zulfiqar Khan le 25 Nov 2018
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 commentaires
Luis Linares
Luis Linares le 7 Mar 2022
so, where in hell is answer to his question?
Walter Roberson
Walter Roberson le 7 Mar 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.

Connectez-vous pour commenter.

Réponse acceptée

madhan ravi
madhan ravi le 25 Nov 2018
Modifié(e) : madhan ravi le 25 Nov 2018
just type
sample %in command window and press enter
  4 commentaires
Luis Linares
Luis Linares le 7 Mar 2022
what does typing sample do?
Steven Lord
Steven Lord le 7 Mar 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.]

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Mobile Fundamentals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by