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 次查看(过去 30 天)
显示 更早的评论
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,'*-');
0 个评论
采纳的回答
KSSV
2022-6-21
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
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) ;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!