Variable lamb1 appears to change size on every loop iteration
Afficher commentaires plus anciens
maximag=max(imag(ee));
lamb1(i1,j1)=maximag;
hello sir i m getting warning as lamb1 changes the size in every loop,because of this warning my program became very slow,can you please help me out.
2 commentaires
Smitesh Patil
le 19 Juil 2021
Are you appending maximag to lamb1 inside a loop? Its not very clear from the example here.
nidhi humnekar
le 19 Juil 2021
Modifié(e) : KSSV
le 19 Juil 2021
Réponses (2)
KSSV
le 19 Juil 2021
You have to initialize that variable before using it in a llop to save/ fill the values.
lamb1 = zeros(m,n) ; % specify your dimensions
3 commentaires
KSSV
le 19 Juil 2021
You need not index lamb1. Simply the below should work.
ee = eig(AA,BB);
maximag=max(imag(ee));
lamb1 = maximag;
switch ivary
case 1
str = 'b-';
case 2
str = 'r-.';
case 3
str = 'k:';
[RA,DA]=meshgrid(Rac,Dac);
contour(RA,DA,lamb1',[0,0],str)
hold on
set(gca,'ytick','log')
set(gca,'xtick',0:5000:35000)
xlabel('Ra')
ylabel('log_10 Da')
% grid on
nidhi humnekar
le 19 Juil 2021
KSSV
le 19 Juil 2021
Show us your complete code...If j1, i1 are your idnices then you have to preallocate/ initialize lamb1.
Smitesh Patil
le 19 Juil 2021
0 votes
This article on Preallocation of arrays should be helpful
Catégories
En savoir plus sur Interactive Control and Callbacks dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!