Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Plotting graphs of a function with an inclusion of i

조회 수: 1 (최근 30일)
Seb apple
Seb apple 2020년 6월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
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'

답변 (1개)

Reshma Nerella
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'

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by