Info
此问题已关闭。 请重新打开它进行编辑或回答。
Plotting graphs of a function with an inclusion of i
1 次查看(过去 30 天)
显示 更早的评论
hi i am trying to plot various graphs for a different values of a constant 'c' i my function. my code is below and i only get a plot when the value of c=0. i believe its to do with the involvment of i in the formula. does anyone know how to go about this?
syms e p n
c=0;
G(n)=e/(2*(p+0.5*(1i*n*c)-(0.25*(n)^2)));
%designing matrix
N = 25;
l_start = ((N-1)/2)-2;
u_start = (N-1)/2;
l_end = l_start-N+3;
u_end = u_start-N+3;
j = diag(ones(1,N)) + diag(G(l_start:-1:l_end), -2) + diag(G(u_start:-1:u_end), 2);
J=det(j)==0;
J = det(J);
fimplicit(J)
%xlim([0 5])
%ylim([0 2.5])
xlabel '\fontsize{21} \bf \epsilon'
ylabel '\fontsize{21} \bf \delta'
0 个评论
回答(1 个)
Reshma Nerella
2020-7-24
Hi,
If you want to plot for different values of c, create an array with the values and traverse through all the elements using a loop.
c = randi(10,1,5); % generate 1x5 array of random numbers from 1 to 10.
syms e p n
hold on % to plot in the same figure for different values of c
for i =1:numel(c) % loop for all values in the array
G(n)=e/(2*(p+0.5*(1i*n*c(i))-(0.25*(n)^2))); % use c(i) instead of c since it is an array
%designing matrix
N = 25;
l_start = ((N-1)/2)-2;
u_start = (N-1)/2;
l_end = l_start-N+3;
u_end = u_start-N+3;
j = diag(ones(1,N)) + diag(G(l_start:-1:l_end), -2) + diag(G(u_start:-1:u_end), 2);
J=det(j)==0;
J = det(J);
fimplicit(J)
end % end of for loop
hold off
%xlim([0 5])
%ylim([0 2.5])
xlabel '\fontsize{21} \bf \epsilon'
ylabel '\fontsize{21} \bf \delta'
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!