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!