Function keeps running into errors when I call it
Show older comments
Hello,
I am running into errors when I try and call my function below by using
[phivalues] = findphases(wpeakt,hpeakt)
%Function below
function [phivalues] = findphases(wpeakt,hpeakt)
newhpeaks = [ ];
phivalues = [ ];
hpeakt = sorteddata.data(:,1);
wpeakt = sorteddata.data(:,5);
for i=1:length(wpeakt)-1;
tau=wpeakt(i+1)-wpeakt(1);
newhpeaks = hpeakt(find(wpeakt(i)<hpeakt<wpeakt(i+1))); %finds haltere value between Tau wing peaks
newhpeaks = newhpeaks(1); %finds "first" neural spike
deltat=newhpeaks-wpeakt(i);
phi=2*pi*(deltat/tau);
phivalues = [phivalues phi];
end
plot(wpeakt,ones(size(wpeakt)),'bo');% ones is y axis
hold on
plot(hpeakt,ones(size(hpeakt)),'ro');
end
The data is being imported as a 1x1 struct, which is why hpeakt and wpeakt are sorteddata.data. hpeakt is all of column 1, and wpeakt is all of column 5. When I call the function I get the error "Unrecognized function or variable 'wpeakt'." When I highlight the entire function script without the function line it comes up fine with my graph and everything. I'm not sure why I am running into issues calling it though. I have my function file named "findphases."
I am also getting the error
>> [phivalues] = findphases(wpeakt,hpeakt)
Unable to resolve the name sorteddata.data.
Error in findphases (line 5)
hpeakt = sorteddata.data(:,1);
Any help is appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!