MATLAB doesn't give an answer for this Waterfall graph and runs this continuously, what's wrong with this?
2 次查看(过去 30 天)
显示 更早的评论
a = linspace(0.01, 10, 4001);
r = linspace(0.1, 10, 4001);
for i = 1:numel(a)
for j = 1:numel(r)
X(i, j)=(a(i)*r(j)^2)/((r(j)^3)-(a(i))*r(j)+a(i));
end
end
figure;
waterfall(r, a, X');
xlabel('r');
ylabel('a');
zlabel('X');
title('3D Waterfall Plot for X=(a*r^2)/((r^3)-(a)*r+a)');
0 个评论
采纳的回答
Walter Roberson
2024-2-11
编辑:Walter Roberson
2024-2-11
You need to vectorize
Reduced size here to fit within the time limits.
a = linspace(0.01, 10, 401);
r = linspace(0.1, 10, 401);
X = (a(:).*r.^2) ./ ((r.^3) - (a(:)) .* r + a(:));
figure;
waterfall(r, a, X');
xlabel('r');
ylabel('a');
zlabel('X');
title('3D Waterfall Plot for X=(a*r^2)/((r^3)-(a)*r+a)');
3 个评论
Walter Roberson
2024-2-11
X has negative values. Log of negative values is complex, and waterfall cannot construct plots with complex coordinates.
In the below, I set those coordinates to NaN.
a = linspace(0.01, 10, 401);
r = linspace(0.1, 10, 401);
X = (a(:).*r.^2) ./ ((r.^3) - (a(:)) .* r + a(:));
figure;
Lx = log(X);
Lx(imag(Lx)~=0) = nan;
waterfall(r, a, Lx');
xlabel('r');
ylabel('a');
zlabel('X');
title('3D Waterfall Plot for X=(a*r^2)/((r^3)-(a)*r+a)');
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!