refcurve
プロットへの参照曲線の追加
構文
refcurve(p)
refcurve
refcurve(ax,p)
hcurve = refcurve(...)
説明
refcurve(p)
は、係数 p
をもつ多項式参照曲線を現在の軸に追加します。p
が n+1
要素をもつベクトルの場合、曲線は以下のとおりです。
y = p(1)*x^n + p(2)*x^(n-1) + ... + p(n)*x + p(n+1)
入力引数のない refcurve
は、x 軸に沿ってラインを追加します。
refcurve(ax,p)
は、Axes
オブジェクト ax
で指定されたプロットの座標軸を使用します。詳細については、axes
を参照してください。
hcurve = refcurve(...)
は、前の構文におけるいずれかの入力引数の組み合わせを使用して、ハンドル hcurve
を曲線に返します。
例
母集団平均関数と近似平均関数の追加
多項式トレンドをもつデータを生成します。
p = [1 -2 -1 0]; t = 0:0.1:3; rng default % For reproducibility y = polyval(p,t) + 0.5*randn(size(t));
データをプロットし、refcurve
を使用して、母集団平均関数を追加します。
plot(t,y,'ro') h = refcurve(p); h.Color = 'r';
近似平均関数も追加します。
q = polyfit(t,y,3); refcurve(q) legend('Data','Population Mean','Fitted Mean', ... 'Location','NW')
refcurve
を使用した打球の軌跡をプロット
関連する物理定数を導入します。
M = 0.145; % Mass (kg) R = 0.0366; % Radius (m) A = pi*R^2; % Area (m^2) rho = 1.2; % Density of air (kg/m^3) C = 0.5; % Drag coefficient D = rho*C*A/2; % Drag proportional to the square of the speed g = 9.8; % Acceleration due to gravity (m/s^2)
各時間区間の加速度は一定であると推測し、速度の二乗に比例する、バットを引いて (ドラッグして) 打ったボールの軌跡をシミュレートします。
dt = 1e-2; % Simulation time interval (s) r0 = [0 1]; % Initial position (m) s0 = 50; % Initial speed (m/s) alpha0 = 35; % Initial angle (deg) v0 = s0*[cosd(alpha0) sind(alpha0)]; % Initial velocity (m/s) r = r0; v = v0; trajectory = r0; while r(2) > 0 a = [0 -g] - (D/M)*norm(v)*v; v = v + a*dt; r = r + v*dt + (1/2)*a*(dt^2); trajectory = [trajectory;r]; end
trajectory
をプロットし、refcurve
を使用してバットを引かずに (ドラッグしない) 打ったボールの放物型軌跡 (解析的に求める) を、この軌跡のプロットに追加します。
figure plot(trajectory(:,1),trajectory(:,2),'m','LineWidth',2) xlim([0,250]) h = refcurve([-g/(2*v0(1)^2),... (g*r0(1)/v0(1)^2) + (v0(2)/v0(1)),... (-g*r0(1)^2/(2*v0(1)^2)) - (v0(2)*r0(1)/v0(1)) + r0(2)]); h.Color = 'c'; h.LineWidth = 2; axis equal ylim([0,50]) grid on xlabel('Distance (m)') ylabel('Height (m)') title('{\bf Baseball Trajectories}') legend('With Drag','Without Drag')
バージョン履歴
R2006a より前に導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)