Multiple errors- Not that great at Matlab :(
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello , any help would be greatly appreciated!
I am running the "TenStory_TMD_Vb".m and it is giving back errors coming from the DynamicResponse.m file. I am not sure how to fix this, please help. Below are the errors I am getting:
Error using DynamicResponse/parfor%supply_1
Index in position 2 exceeds array bounds. Index must not exceed 1.
Error in DynamicResponse (line 3)
parfor ii=1:Num_point
Error in TenStory_TMD_Vb (line 34)
[ Base_shear ] = DynamicResponse(Num_point, w, n, t, ACC);
0 commentaires
Réponses (2)
Raymond Norris
le 24 Sep 2023
The parallel for-loop is exposing an issue you would find if you ran it with a serial for-loop, namely
Error using interp1>reshapeAndSortXandV
X and V must be of the same length.
Error in interp1 (line 128)
[X,V,orig_size_v] = reshapeAndSortXandV(X,V);
Error in fun (line 3)
acc=interp1(tf,ACC,t);
Error in DynamicResponse>@(t,Z)fun(t,Z,n,M,K,C,acc,tf) (line 34)
[~,XX]=ode15s(@(t,Z) fun(t,Z,n,M,K,C,acc,tf),tf,IC);
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 153)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in DynamicResponse (line 34)
[~,XX]=ode15s(@(t,Z) fun(t,Z,n,M,K,C,acc,tf),tf,IC);
Error in TenStory_TMD_Vb (line 34)
[ Base_shear ] = DynamicResponse(Num_point, w, n, t, ACC);
Change the parfor in DynamicResponse, line 3 to a for-loop and resolve this first and then revert back to parfor.
Side note: you'll notice quite a few MATLAB Code Analyzer messages indicating that you haven't preallocated your matrix. I would suggest going through to see what you can do -- it might shock you to see the improvements preallocation can make.
0 commentaires
William Rose
le 23 Sep 2023
Modifié(e) : William Rose
le 23 Sep 2023
It looks like 3 errors but it is really only one error.
Error using DynamicResponse/parfor%supply_1
Index in position 2 exceeds array bounds. Index must not exceed 1.
Matlab does not like something about this parallel for loop. "Index in position 2 exceeds array bounds" means Matlab is trying to access element 2 of an array that only has one element. I don't know what supply_1 is, and I have not used parfor loops. I recommend you replace parfor with for, to see if it runs when you do not try to parallelize the code.
Error in DynamicResponse (line 3)
parfor ii=1:Num_point
The message above tells you that function DynamicResponse had an error at line 3 - due to the parfor problem reported above.
Error in TenStory_TMD_Vb (line 34)
[ Base_shear ] = DynamicResponse(Num_point, w, n, t, ACC);
This tells you that line 34 of TenStory_TMD_Vb had an error at line 34. And it is because of the error in DynamicResponse.m, reported above.
This is standard - an error in a sub-sub-program produces error messages going up the chain of programs that called it.
1 commentaire
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!