(Error using vertcat) Dimensions of arrays being concatenated are not consistent
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88596.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88514.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88516.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88513.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88595.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88512.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88517.csv
- XYZ_Internal_Table_FINAL_95mm_tableff=100Hz_95mm_88515.csv
Hello all,
Here is my code. Some related .csv files are attached.
After running the code, I face this error:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in Code_Yahya (line 105)
phia =[x;y;phix(:,a)';phiy(:,a)'];
>> both phix and phiy are of same sizes.
Can someone help me here ?
Thank you
%%% Tables are exported as vertices from STARCCM+
%%% ------------------------------------------------------------------%%%
clear; clc; close all;
f=dir('*.csv'); % finding all csv files
n_snapshots=size(f,1); % finding number of snapshots
for i=1:n_snapshots
fn=f(i).name; % Listing filenames
fid=fopen(fn, 'r'); % reading files
data = fscanf(fid, '%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f' , [11, inf]);
% exporting columns
x=data(9,:);
y=data(10,:);
%Ut(:,i) = data(:,1);
u(:,i) = data(:,3);
v(:,i) = data(:,2);
fclose(fid);
end
%--------------------------------------------------------------
u = permute(u,[2 1]);
%Split u into two snapshot sets
X1 = u(:,1:end-1);
X2 = u(:,2:end);
%SVD on X1
[Ux, Sx, Vx] = svd(X1,'econ');
%Compute DMD (phix are Eigen vectors)
r = 3; %truncate as 10 modes
%Reduce rank
Ux = Ux(:,1:r);
Sx = Sx(1:r,1:r);
Vx = Vx(:,1:r);
%Gets A_tilde
A_tildex = Ux'*X2*Vx/Sx;
%Compute A_tilde eigenvalues and eigenvectors
%[eVecs, Eigenvalues] = eig(A_tilde);
[Wx, eigsx] = eig(A_tildex);
%DMD modes
phix = X2*Vx/Sx*Wx; %Eigenvectors
figure
theta = (0:1:100)*2*pi/100;
plot(cos(theta),sin(theta),'k--') % plot unit circle
hold on, grid on
scatter(real(max(eigsx)),imag(max(eigsx)),'ok')
axis([-1.1 1.1 -1.1 1.1]);
%--------------------------------------------------------------
v = permute(v,[2 1]);
%Split u into two snapshot sets
Y1 = v(:,1:end-1);
Y2 = v(:,2:end);
%SVD on X1
[Uy, Sy, Vy] = svd(Y1,'econ');
%Compute DMD (phix are Eigen vectors)
r = 3; %truncate as 10 modes
%Reduce rank
Uy = Uy(:,1:r);
Sy = Sy(1:r,1:r);
Vy = Vy(:,1:r);
%Gets A_tilde
A_tildey = Uy'*Y2*Vy/Sy;
%Compute A_tilde eigenvalues and eigenvectors
%[eVecs, Eigenvalues] = eig(A_tilde);
[Wy, eigsy] = eig(A_tildey);
%DMD modes
phiy = Y2*Vy/Sy*Wy; %Eigenvectors
figure
theta = (0:1:100)*2*pi/100;
plot(cos(theta),sin(theta),'k--') % plot unit circle
hold on, grid on
scatter(real(max(eigsy)),imag(max(eigsy)),'ok')
axis([-1.1 1.1 -1.1 1.1]);
%--------------------------------------------------------------
Gridnumber = size(x, 2);
for j=1:r %n_snapshots
phinor = 0;
for i=1:r %Gridnumber
phinor = phinor + power(phix(i,j),2) + power(phiy(i,j),2);
%phinor = phinor + power(phix(i,j),2);
end
phinor = sqrt(phinor);
phix(:, j) = phix(:, j) / phinor;
phiy(:, j) = phiy(:, j) / phinor;
end
%Extracting modes
for a=1:r %n_snapshots
FilNamPhi=1000+a; %FilNamPhi=1000+a;
PhiOut = fopen([num2str(FilNamPhi), '.txt'], 'wt');
fprintf(PhiOut,'');
phia =[x;y;phix(:,a)';phiy(:,a)'];
fprintf(PhiOut, '%20.9f %20.9f %20.9f %20.9f\n',phia);
fclose(PhiOut);
end
%xlswrite('eigenvaluesX.xlsx',[real(max(eigsx))',imag(max(eigsx))'];
%xlswrite('eigenvaluesY.xlsx',[real(max(eigsy))',imag(max(eigsy))'];
0 comentarios
Respuestas (1)
Torsten
el 19 de Jun. de 2025
Movida: Torsten
el 19 de Jun. de 2025
x and y are of size 1x500, phix(:,a)' and phiy(:,a)' are of size 1x8. So either x and y had to be of size 1x8 or phix(:,a)' and phiy(:,a)' had to be of size 1x500 for that phia =[x;y;phix(:,a)';phiy(:,a)']; would make sense.
7 comentarios
Torsten
el 20 de Jun. de 2025
The number of rows of Ux is 20, but the number of columns of Ux is 10. Thus still r <= 10 is required.
Ver también
Categorías
Más información sobre Stress and Strain en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!