ASedJavad
یک شنبه 29 تیر 1393, 12:49 عصر
سلام
چطور میشه یک بیضی رو با داشتن بردارهای شعاع بزرگ و کوچکش رسم کرد؟
یعنی طبق تصویر ،با داشتن دو بردار u1 و u2 بیضی رو رسم کنیم؟
121320
ASedJavad
یک شنبه 29 تیر 1393, 13:11 عصر
جوابش رو خودم پیدا کردم:
function ellips( u1,u2 )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
%
% Standard 2D cartesian coordinates
% Minor and Major semi-axes in an ellipse
if isequal(size(u1),size([1 1]))
ax1 = u1';
else
ax1=u1;
end
if isequal(size(u2),size([1 1]))
ax2 = u2';
else
ax2=u2;
end
% 2*pi takes you around the unit circle
theta = 0:(pi/64):(2*pi);
% Plot the ellipse
plot( ax1(1)*cos(theta)+ax2(1)*sin(theta), ...
ax1(2)*cos(theta)+ax2(2)*sin(theta), ...
'r-')
% hold the figure, so we can add to it
hold on
% Plot the semi-axes
plot( [0 ax1(1)], [0 ax1(2)], 'b--d' )
plot( [0 ax2(1)], [0 ax2(2)], 'b--x' )
% OK, we're done with this plot
hold off
% turn on the grid in the plot
grid on
% make the plot square (so circles look like circles!)
axis('square')
end
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.