unrecognized function or variable

조회 수: 8 (최근 30일)
Gonzalo Guerrero
Gonzalo Guerrero 2020년 7월 21일
편집: Gonzalo Guerrero 2020년 7월 21일
Hi all,
I am creating a script to analyse a big file of data imported from a .txt file. The file is a 20223208x8. I used the following code:
Spike2= importdata('ESprematlab3.txt');
Spike=Spike2.data;
function out=Stimulus_output(Spike)
Spike=[Spike]
time=Spike(:,1);
DigiMarker=Spike(:,2);
TMS=Spike(:,4);
ES=Spike(:,5);
RF=Spike(:,7);
force=Spike(:,8);
Muscle1=[];
Time=[];
n=1;
%sample Rate is the Rate that you export the .txt file from Spike.
%Recommended 5000 or more. However, This script is made for 5000. if you
%change it, you may want to also change the MEP or LEP cut below
SampleRate=5000;
%create a Cell with different
Tableresults=cell(n,8);
for
.
.
.
end
out=Tableresults
end
So, what I have tried to achive is getting a Tableresults with different values obtain from the data attaching them.
  댓글 수: 2
KSSV
KSSV 2020년 7월 21일
Which variable/ function is unrecognised? Give us the full error here.
Gonzalo Guerrero
Gonzalo Guerrero 2020년 7월 21일
Unrecognized function or variable 'Stimulus_output'. This is what I actually get.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 7월 21일
You are defining a function inside a script, but you are not calling the function inside the script. Therefore you must be trying to call the function outside of the script. However functions defined inside scripts are local functions, just like functions that are not the first function in a function file are local. You cannot invoke local functions from outside (unless a handle gets exported somehow.)
Save the function to its own file.
  댓글 수: 1
Gonzalo Guerrero
Gonzalo Guerrero 2020년 7월 21일
편집: Gonzalo Guerrero 2020년 7월 21일
I think I understand what you mean, but I need to call the function from the command window, since there are many files to analyse and they have different names. I saved the function, getting rid of the first two lanes as 'Stimulus_output.m.' . then I called the function on the command window with:
Spike2= importdata('ESprematlab3.txt');
Spike=Spike2.data;
out=Stimulus_output(Spike)
I still get the same result.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by