Ellipsoid plot_ wireframe view

조회 수: 2 (최근 30일)
Vikas Saroha
Vikas Saroha 2019년 8월 26일
댓글: Vikas Saroha 2019년 8월 26일
Hello, I have plotted ellipsoids using 'surf' command at some fixed points. It looks like solid. But i want to see three axis of it as shown in figure attached. Please suggest.
  댓글 수: 1
darova
darova 2019년 8월 26일
Draw additional lines using plot3()?

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2019년 8월 26일
편집: Bruno Luong 2019년 8월 26일
[Q,~] = qr(randn(3));
h = rand(3,1);
h1 = h(1);
h2 = h(2);
h3 = h(3);
% If your principal axis are (3x1) P1, P2, P3 and half length are (scalars) h1, h2, h3
% Q = [P1(:), P2(:), P3(:)];
Q = Q .* ([h1, h2, h3]./sqrt(sum(Q.^2,1)));
n = 21;
[x,y,z]=sphere(n);
xyz = Q*[x(:) y(:) z(:)]';
x = reshape(xyz(1,:),[n n]+1);
y = reshape(xyz(2,:),[n n]+1);
z = reshape(xyz(3,:),[n n]+1);
close all
hold on
surf(x,y,z,'EdgeColor',0.6+[0 0 0],'FaceColor','none');
for k=1:3
plot3([0 Q(1,k)],[0 Q(2,k)],[0 Q(3,k)],'r','LineWidth',2);
end
axis equal
This is a slight modification of my answer in this thread
  댓글 수: 3
Bruno Luong
Bruno Luong 2019년 8월 26일
Error occuring or not depends on your MATLAB version, this command is correct for R2016b and later.
If you use previous you should replace with
Q = bsxfun(@times, Q, ([h1, h2, h3]./sqrt(sum(Q.^2,1))))
Vikas Saroha
Vikas Saroha 2019년 8월 26일
thanks for your prompt reply. Its working.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by