Unable to perform assignment because the size of the left side is 111-by-1 and the size of the right side is 112-by-1.

1 view (last 30 days)
Hi,
I am unable to figure it out or understand what is happening here. i am trying to do the plotting of certain column from 3 csv files (files are attached) but getting the error below.
Error:
Unable to perform assignment because the size of the left side is 111-by-1 and the size of the right side is 112-by-1.
Error in FlushFlow_DataComparison (line 11)
col_1_distance(:,i) = table2array( data(:,1) ); % get the 13th column of each file
Code:
close all; clear all; clc;
P = 'F:\3-PIV_Experimental_Data\Calculations_TurbulentIntensity\line_Data\LSA_FlushflowMag_Data';
S = dir(fullfile(P,'*.csv'));
N = natsortfiles({S.name});
for i = 1:numel(N);
data = readtable( fullfile(P, N{i}) ); % read the csv files
col_1_distance(:,i) = table2array( data(:,1) ); % get the 13th column of each file
col_7_TurbulentIntensity(:,i) = table2array( data(:,7) );
end
plot (col_1_distance,col_7_TurbulentIntensity,'*-');

Accepted Answer

KSSV
KSSV on 21 Jun 2022
The error is siimple, you are trying to save more number of elements than the array is initialized for.
A = zeros(2,3) ; % 2x3 matrix is initialized
A(1,:) = rand(1,2) ; % no error, 1 1x2 array is saved
Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is 1-by-2.
A(2,:) = rand(1,3) ; % error, you cannot save 1x3 array into 1x2
In the same, way check your initialized array dimensions. If you are sure of array size, initiailze it as a matrix. If not initialize it as cell .
B = cell(2,1) ;
B{1} = rand(1,2) ;
B{2} = rand(1,3) ;

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!