Filter löschen
Filter löschen

How to run a script on Matlab?

92 Ansichten (letzte 30 Tage)
Zulfiqar Khan
Zulfiqar Khan am 25 Nov. 2018
Kommentiert: Walter Roberson am 7 Mär. 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 Kommentare
Luis Linares
Luis Linares am 7 Mär. 2022
so, where in hell is answer to his question?
Walter Roberson
Walter Roberson am 7 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

madhan ravi
madhan ravi am 25 Nov. 2018
Bearbeitet: madhan ravi am 25 Nov. 2018
just type
sample %in command window and press enter
  4 Kommentare
Luis Linares
Luis Linares am 7 Mär. 2022
what does typing sample do?
Steven Lord
Steven Lord am 7 Mär. 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.]

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Mobile Fundamentals 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