Error Message "Unrecognized function or variable"

조회 수: 1 (최근 30일)
Mary Hemler
Mary Hemler 2020년 6월 2일
답변: Star Strider 2020년 6월 2일
I have run this script several times successfully, but I made a few changes to the folders where I was storing files and variables, and now I am getting this error message:
Unrecognized function or variable 'pcaBinnedSpikes'.
Error in M28_PoS_PCA (line 27)
[coeff, score, latent, tsquared, explained, mu] = pca(pcaBinnedSpikes');
Here is the code:
% State Space Visualization and PCA
% Pre-Process Data
headangledeg = rad2deg(headangle); % convert from radians to degrees
startTime = trackingtimes(1);
stopTime = trackingtimes(end);
% Make a matrix of activity for all neurons that 'spiked' at least 1000 times during the session. The shape of the matrix should be N by T, where N is the number of neurons and T is the number of time bins. Use the binning from the tracked head direction. Smooth the activity of each neuron with a Gaussian with ? = 10 time bins and then standardize the activity: (activity-mean(activity))/standard deviation(activity).
j=1;
for c=1:length(M28_PoS_spikes)
if ~idx(c)
continue
end
spikes = M28_PoS_spikes{c};
spikes = spikes(spikes > startTime & spikes < stopTime);
if length(spikes) >= 1000
edgesT = linspace(startTime,stopTime,numel(trackingtimes)+1);
binnedSpikes = histcounts(spikes,edgesT);
binnedSpikes = smoothdata(binnedSpikes,2,'gaussian',50);
pcaBinnedSpikes(j,:) = zscore(binnedSpikes);
j = j+1;
end
end
% Run PCA
% Reduce the dimensionality of the matrix from N by T to 2 using Principal Component Analysis (PCA)
[coeff, score, latent, tsquared, explained, mu] = pca(pcaBinnedSpikes');
% Visualize the Population Activity
% Make a plot of the time points of the experiment, color-coded according to tracked head direction angle
figure
colormap hsv
scatter(score(:,1),score(:,2),15,headangle,'.')
axis equal
xlabel('1st Principal Component')
ylabel('2nd Principal Component')
title('Mouse 28 PoS PCA - High MI','FontSize',12)
I do define pcaBinnedSpikes, so I am not sure why I get the error message now.

채택된 답변

Star Strider
Star Strider 2020년 6월 2일
Note that ‘pcaBinnedSpikes’ is assigned within an if block.
If the if condition is never satisfied, ‘pcaBinnedSpikes’ will never be created.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by