Unable to perform assignment because the left and right sides have a different number of elements.
1 次查看(过去 30 天)
显示 更早的评论
Hi, everyone
This is my code, but when I'm doing to run it.. appears this error:
Unable to perform assignment because the left and right sides have a different number of elements. In particular in this line: correlation(t) = corrcoef(LFP1_t, LFP2_t). But LFP1_t ed LFP2_t are both two vectors of 1000x1.
How can I fix the problem?
start_stop_plot = [871.620 1015.860];
window = 1*new_fs; % 1 second of window
start_stop_plot_points = [start_stop_plot(1)*new_fs, start_stop_plot(2)*new_fs];
correlation = zeros(start_stop_plot_points(2)-start_stop_plot_points(1),1);
for t=start_stop_plot_points(1):start_stop_plot_points(2)-window;
LFP1_t = data_1(t:t+window-1);
LFP2_t = data_2(t:t+window-1);
correlation(t) = corrcoef(LFP1_t, LFP2_t);
end
figure
plot(new_time(start_stop_plot_points(1):start_stop_plot_points(2)),...
correlation(start_stop_plot_points(1):start_stop_plot_points(2)),'black');
xlabel('Time (s)'); ylim([-1 1])
0 个评论
回答(1 个)
Jan
2022-11-21
编辑:Jan
2022-11-21
"But LFP1_t ed LFP2_t are both two vectors of 1000x1." - yes, of course, but the left side of the assignment correlation(t) is a scalar.
correlation(t) = corrcoef(LFP1_t, LFP2_t)
% [1x1] = [2 x 2] ==> Error!
2 个评论
Jan
2022-11-21
I assume, I cannot guess this. How would you like to solve this? It depends on what you want to implement. Currently you assume, that you can store the output of the corrcoef function in a scalar. I cannot know, what you want to do instead.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!