Performing a parametric sweep in Matlab

조회 수: 52 (최근 30일)
Joseph
Joseph 2016년 5월 4일
댓글: Star Strider 2016년 5월 5일
Hello, I have an equation for the motion of a spring. I need to perform a parametric sweep by varying two of the constants in the equation and seeing the effect that it has.
M_spring (θ_1 )= (dx+r*sin(θ_3))/(dy+r*cos(θ_3)) *K*L + m_1 l_1 cos(θ_1)* (θ_1dot)
θ_1 = 90º
θ_1dot = 10º/s
θ_3 = 62º
dx = .015 m
dy = .021 m
m_1 = .25*10^-3 kg
l_1 = .006 m
L = .04 m
i need to vary K and r and run a parametric sweep. K = 0 to 500 and r=.05 to .2
can someone please help explain how this is done? Thank You

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 5월 5일
Joseph - given that you have two variables, I suspect that you will want to iterate over each one using two for loops. Perhaps something like
for K=0:1:500 % step size of 1 (guess only)
for r=0.5:0.1:2 % step size of 0.1 (guess only)
% do something with K and r
% save result to matrix
end
end
On each iteration, you will probably want to save the results to a matrix so that you can do a proper comparison once complete.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by