Index in position 2 exceeds array bounds

Hi, I have this script
%%
% DEFINIZIONE PARAMETRI DINAMICI
%DEFINIZIONE vettore frequenze
F_plot=400; %Frequenza limite dell'analisi
df=0.1;
f=[0:df:F_plot];
w=2*pi*f;
%%
% COSTRUZIONE SS
csi=0.0024; % smorzamento percentuale -- 0.05 è il valore nella flexsspf
FREQ_equi=load(['freq_prop.txt']);
pfdx_equi=load(['pffe.txt']);
%modi=[1:length(FREQ_equi)]';
%gamma_equi=pfdx_equi(:,2); % matrice dei fattori di partecipazione modale
save('PF1_equi.dat','pfdx_equi', '-ascii') % | modo | PF1 | PF2 | ... | PFr |
save('FREQ1_equi.dat','FREQ_equi', '-ascii') % | modo | freq
type=1; % 1 se spostamento ( q ), 2 se accelerazione ( q** )
[Aq,Bq,Cq,Dq]=flexsspf('','PF1_equi.dat','freq_prop.txt',csi,type);
sysansq_equi=ss(Aq,Bq,Cq,Dq);
%%
% vado a plottare il modulo della funzione di risposta in frequenza
[mags,phases]=bode(sysansq_equi,w);
[output,input,frequencies]=size(mags);
figure (1)
semilogy(f,squeeze(mags(:,1,:)),'linewidth',1)
hold on
grid on
title('Mag FRFs uscite/ingressi')
xlabel('Frequency [Hz]')
ylabel('Mag FRF [Disp Unit/Force Unit]')
legend('q1','q2','q3','q4','q5','q6','q7','q8','q9','q10');
and this error is occurred
In untitled34 (line 43)
Index in position 2 exceeds array bounds.
Error in untitled34 (line 56)
semilogy(f,squeeze(mags(:,1,:)),'linewidth',1)
Can i solve this problem?

6 Comments

check if mags is empty
mags
mags =
10×0×4001 empty double array
is your flexsspf still the code from https://www.mathworks.com/matlabcentral/answers/1769315-the-a-and-b-matrices-must-have-the-same-number-of-rows ? that code ignores several of its inputs
More or less it is the same, the only differences are these: in flexsspf I inserted the frequency file as .txt instead of .dat, because otherwise it didn't work. Then I removed the number of modes from the input files and then commented "modi" because I don't need it. The fact is that the flexsspf function should work even without the first input which is empty in the script, because in theory only frequencies and pf (participation factors) should suffice
please show the new code

Sign in to comment.

Answers (0)

Products

Release

R2022a

Asked:

on 2 Aug 2022

Commented:

on 2 Aug 2022

Community Treasure Hunt

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

Start Hunting!