Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Plotting graphs of a function with an inclusion of i
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Reshma Nerella
il 24 Lug 2020
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 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!