linspace error while trying to plot
2 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I have written a code for linspace I want a 3D plot of it:
% First we set the constants:
kd=6;
lambda= 0.01;
Delta_E=0.02;
% Then we write down the Formulas:
z=linspace(-1,1,200);
kappa=linspace(0,1,200);
q=((Delta_E)+(lambda.*z)+(((sqrt((1+z)./2)).*exp(-(kd.*(sqrt(2.*lambda'.*(1+z))))))).*(kappa.*(sqrt((1-z)./(1+z)))-(sqrt((1+z)./(1-z )))));
% Now we plot q(Z,kappa) vs Z and kappa :
figure(1)
mesh(z,kappa,q)
% title('kd=6');
xlabel('Z');
ylabel('lambda');
zlabel('q)');
I think that my "q" must have 200*200 matrix, but it is not. Its gives just 1*200.
I would highly appreciate if you help me.
Thanks,
0 件のコメント
採用された回答
Walter Roberson
2017 年 11 月 30 日
Change
z=linspace(-1,1,200);
kappa=linspace(0,1,200);
to
Z = linspace(-1,1,200);
KAPPA = linspace(0,1,200);
[z, kappa] = meshgrid(Z, KAPPA);
Note: you have
ylabel('lambda');
which is not correct. Your lambda is a constant. Your y axes is kappa, not lambda.
2 件のコメント
Walter Roberson
2017 年 11 月 30 日
contour(z, kappa, q, [0 0])
the [0 0] is a trick that has to be used when you are only asking for one contour value; if you were to try to pass in the scalar 0 at that point, it would try to interpret the scalar 0 as the number of contour levels to draw.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!