필터 지우기
필터 지우기

Dimensions of arrays being concatenated are not consistent.

조회 수: 4 (최근 30일)
Matin jaberi
Matin jaberi 2022년 7월 14일
댓글: KSSV 2022년 7월 14일
I have following script. there are 4 txt files where each have diferent array size in columns. how can i read all the fix the error i get
Thanks

답변 (1개)

KSSV
KSSV 2022년 7월 14일
편집: KSSV 2022년 7월 14일
This line:
TimeM = [AA(:,1) BB(:,1) CC(:,1) DD(:,1)] ;
will throw error. Note that BB, CC and DD are of size 20x2 and AA(:,1) is of size 24x2. So you cannot join/ concatenate four columns of size 24x1 and 20x1. Obviously, it will trhow error. So what you can do is:
data = [AA ; BB; CC; DD] ;
TimeM = data(:,1) ;
VoltM = data(:,2) ;
plot(TimeM,VoltM)
  댓글 수: 2
Matin jaberi
Matin jaberi 2022년 7월 14일
is there a way to get join them in seperate column? i dont wan to get a column of 84x1
KSSV
KSSV 2022년 7월 14일
Yes, you can. You can interpolate AA from 24x2 to 20x2 or interpolate BB, CC, DD from 20x2 to 24x2. I have shown below converting AA from 24x2 to 20x2. You need to read about interp1.
x = AA(:,1) ;
y = AA(:,2) ;
xi = linspace(min(x),max(x),20)' ;
yi = interp1(x,y,xi) ;
AA = xi yi] ;
TimeM = [AA(:,1) BB(:,1) CC(:,1) DD(:,1)] ;

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by