Clear Filters
Clear Filters

Unable to perform assignment because the left and right sides have a different number of elements.

1 view (last 30 days)
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])

Answers (1)

Jan
Jan on 21 Nov 2022
Edited: Jan on 21 Nov 2022
"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 Comments
Jan
Jan on 21 Nov 2022
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.

Sign in to comment.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!