How to run a script on Matlab?
조회 수: 177 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2022년 3월 7일
The answer is below at https://www.mathworks.com/matlabcentral/answers/431763-how-to-run-a-script-on-matlab#answer_348735
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.
채택된 답변
madhan ravi
2018년 11월 25일
편집: madhan ravi
2018년 11월 25일
just type
sample %in command window and press enter
댓글 수: 4
Steven Lord
2022년 3월 7일
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.]
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!