필터 지우기
필터 지우기

Variable lamb1 appears to change size on every loop iteration

조회 수: 2 (최근 30일)
nidhi humnekar
nidhi humnekar 2021년 7월 19일
댓글: KSSV 2021년 7월 19일
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
Smitesh Patil
Smitesh Patil 2021년 7월 19일
Are you appending maximag to lamb1 inside a loop? Its not very clear from the example here.
nidhi humnekar
nidhi humnekar 2021년 7월 19일
편집: KSSV 2021년 7월 19일
ee = eig(AA,BB);
maximag=max(imag(ee));
lamb1(j1,i1)=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

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

답변 (2개)

KSSV
KSSV 2021년 7월 19일
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
nidhi humnekar
nidhi humnekar 2021년 7월 19일
thank you so much sir,but when i m not definig index for lamb1 it is showing
Error using contour (line 48)
Z must be at least a 2x2 matrix.
contour(RA,ALPHA,lamb1',[0,0],str)
KSSV
KSSV 2021년 7월 19일
Show us your complete code...If j1, i1 are your idnices then you have to preallocate/ initialize lamb1.

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


Smitesh Patil
Smitesh Patil 2021년 7월 19일
This article on Preallocation of arrays should be helpful

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by