Clear Filters
Clear Filters

Performing a parametric sweep in Matlab

38 views (last 30 days)
Joseph
Joseph on 4 May 2016
Commented: Star Strider on 5 May 2016
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

Answers (1)

Geoff Hayes
Geoff Hayes on 5 May 2016
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.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!