INVERT first three rows of results

1 次查看(过去 30 天)
I obtain these results... I want to invert first three rows of first column with first three rows of second columns.
So to have first column all positive and second all negative.
What can i do?
syms beta gamma
OA=1.42;
AB=4.3;
BO=3.33;
OO=6;
alfa=linspace(19.7, -103, 14);
% preallocate solution arrays
result_beta = nan(numel(alfa),2);
result_gamma = nan(numel(alfa),2);
% solve and save the results
for k = 1:numel(alfa)
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
result_beta(k,:)=double(res_beta);
result_gamma(k,:)=double(res_gamma);
disp (result_gamma)
end
results:
56.3136 -68.0355
60.0422 -66.3337
63.3157 -63.8261
-60.6513 65.9511
-56.9882 67.8010
-53.0279 68.7742
-48.9467 68.8414
-44.8871 68.0280
-40.9515 66.3985
-37.2048 64.0403
-33.6824 61.0509
-30.3996 57.5285
-27.3598 53.5685
-24.5623 49.2618

采纳的回答

madhan ravi
madhan ravi 2019-2-4
Alternatively:
results(1:3,[1 2])=results(1:3,[2 1])
  5 个评论
pablolama
pablolama 2019-2-4
i've posted
syms beta gamma
OA=1.42;
AB=4.3;
BO=3.33;
OO=6;
alfa=linspace(19.7, -103, 14);
% preallocate solution arrays
result_beta = nan(numel(alfa),2);
result_gamma = nan(numel(alfa),2);
% solve and save the results
for k = 1:numel(alfa)
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
result_beta(k,:)=double(res_beta);
result_gamma(k,:)=double(res_gamma);
result_beta(1:3,[1 2])=result_beta(1:3,[2 1])
result_gamma(1:3,[1 2])=result_gamma(1:3,[2 1])
end
madhan ravi
madhan ravi 2019-2-4
I said after the loop not inside the loop.

请先登录,再进行评论。

更多回答(1 个)

madhan ravi
madhan ravi 2019-2-4
results(1:3,:)=fliplr(results(1:3,:))

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by