How to plot two equation consequetively

1 view (last 30 days)
Hi, I have written this code and need to plot jlralph and jlrgamma in a continuous way from 0 to alpharange and alpharange to alpharange2 respectively.
mc0 = -0.5;
jlr0 = -0.8;
M = 0.99;
alpharange = 6.5; %// degrees
alpharange2 = 180; %// degrees
mcalpha = (mc0 - (1 / M) - 1) * cos(alpharange) + jlr0 * sin(alpharange) + (1/M) + 1
jlralpha = ((-mc0) + (1 / M) + 1) * sin(alpharange) + jlr0 * cos(alpharange)
for i=0:1:alpharange
jlralph = ((-mc0) + (1 / M) + 1) * sin(i) + jlr0 * cos(i)
for x=alpharange:1:alpharange2
jlrgamma = ((-mcalpha) + (1 / M) - 1) * sin(x- alpharange) + jlralpha * cos(x- alpharange);
end
end
How do I do that

Accepted Answer

Walter Roberson
Walter Roberson on 7 Dec 2016
mc0 = -0.5;
jlr0 = -0.8;
M = 0.99;
alpharange = 6.5; %// degrees
alpharange2 = 180; %// degrees
mcalpha = (mc0 - (1 / M) - 1) * cosd(alpharange) + jlr0 * sind(alpharange) + (1/M) + 1;
jlralpha = ((-mc0) + (1 / M) + 1) * sind(alpharange) + jlr0 * cosd(alpharange);
%above here I only changed sin to sind and cos to cosd
%below here is vectorized computations. Note sin and cos changed to sind and cosd
alpha1 = linspace(0, alpharange);
jlralph = ((-mc0) + (1 / M) + 1) * sind(alpha1) + jlr0 * cosd(alpha1);
alpha2 = linspace(alpharange, alpharange2);
jlrgamma = ((-mcalpha) + (1 / M) - 1) * sind(alpha2 - alpharange) + jlralpha * cosd( alpha2 - alpharange);
plot([alpha1, alpha2], [jlralph, jlrgamma])

More Answers (0)

Categories

Find more on Matrix Decomposition 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!