フィルターのクリア

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