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!