Problem in contour plot using ''for '' loop.

6 ビュー (過去 30 日間)
AVM
AVM 2020 年 6 月 24 日
コメント済み: KSSV 2020 年 6 月 24 日
I would like to get a contour plot in the following code, but some prolem is occuring. Please somebody help me to solve that.
clc;
syms t g
n=6;
I1=eye(n);
I2=eye(2);
matdimension= n-1;
tempvector = 0:1:matdimension;
tempvector = sqrt(tempvector);
tempmatrix = diag(tempvector);
anni= circshift(tempmatrix,-1);
crea = anni';
num=crea*anni;
c=crea+anni;
sigx=[0,1;1,0];
t=0:0.01:1;
g=0.0001:0.01:0.49;
M= zeros(size(t));
for i = 1:length(t)
for k=1:length(g)
A= g(k).*kron(I2,num)+ t(i)*kron(sigx,c);
[~,v]=eig(A);
M(i)=v(2,2);
[T,G]=meshgrid(t,g); %%%%%%%%%% upto this line it is working......
F=M(T,G); %%%%%% for here the problem is starting.
end
end
contourf(T,G,F)
colormap(cool)
%%%%%%%%%%%%%%output error
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in tial (line 35)
F=M(T,G);
  2 件のコメント
KSSV
KSSV 2020 年 6 月 24 日
What is the purpose of this?
F=M(T,G); %%%%%% for here the problem is starting
Offcourse, it will give error...
AVM
AVM 2020 年 6 月 24 日
編集済み: AVM 2020 年 6 月 24 日
Actually I need to see how the contour plot looks like in this case and I have to compare it with other system of equations.

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2020 年 6 月 24 日
May be you are looking for
contour(T,G,M)
  2 件のコメント
AVM
AVM 2020 年 6 月 24 日
Actually by anyway I need to plot that contour (t,g,m). I thought that some meshgrid has to be assigned first within the for loop and define M as M(T,G). But it is not woking. Please, help me to get that. I do this using foor loop because the eigenvalue calculation is taking long time symbolically. It will take even more time if I increase the dim. of the matirx A.
KSSV
KSSV 2020 年 6 月 24 日
There is no need to use syms...you can remove it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by