matlab 想留住一组正实数解ans =[ .1846536138869924146643935,7.986748005492751499324976,1421.3443803903520135420418095598][ .1845273287168265848989651-.518860744535330417140e-4*i,7.98128584415339900082029-.224420737255765751358e-2*i,-921.90365
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 02:57:26
matlab 想留住一组正实数解ans =[ .1846536138869924146643935,7.986748005492751499324976,1421.3443803903520135420418095598][ .1845273287168265848989651-.518860744535330417140e-4*i,7.98128584415339900082029-.224420737255765751358e-2*i,-921.90365
matlab 想留住一组正实数解
ans =
[ .1846536138869924146643935,7.986748005492751499324976,1421.3443803903520135420418095598]
[ .1845273287168265848989651-.518860744535330417140e-4*i,7.98128584415339900082029-.224420737255765751358e-2*i,-921.90365305631302770115467835537+2642.4306206792349087655207542102*i]
[ 1.1366167570295502195622499015334,49.161624438994386659266864253174,-.51369034214749980310243736041245e-2]
[ -.17556935386503744353325080508e-2,-.75938301844739378690852424348e-1,-.99214670347055175139636111517488]
[ .320434219084204372529383330975e-1,1.385961155208496420974841396949,-1.1750983631415945437001650354278]
[ .1845273287168265848989651+.518860744535330417140e-4*i,7.98128584415339900082029+.224420737255765751358e-2*i,-921.90365305631302770115467835537-2642.4306206792349087655207542102*i]
有这样一组解,由于是实际问题,负数和虚数是不符合条件的,怎么能得到我要的整实数解啊,请大侠们帮忙了.
我用rea()>0和imag()=0语句挑选出来的结果有7个,我怎么得到第一行的那个解啊?
matlab 想留住一组正实数解ans =[ .1846536138869924146643935,7.986748005492751499324976,1421.3443803903520135420418095598][ .1845273287168265848989651-.518860744535330417140e-4*i,7.98128584415339900082029-.224420737255765751358e-2*i,-921.90365
修改后的
clc
clear
format long
date=[[ .1846536138869924146643935,7.986748005492751499324976,1421.3443803903520135420418095598]
[ .1845273287168265848989651-.518860744535330417140e-4*i,7.98128584415339900082029-.224420737255765751358e-2*i,-921.90365305631302770115467835537+2642.4306206792349087655207542102*i]
[ 1.1366167570295502195622499015334,49.161624438994386659266864253174,-.51369034214749980310243736041245e-2]
[ -.17556935386503744353325080508e-2,-.75938301844739378690852424348e-1,-.99214670347055175139636111517488]
[ .320434219084204372529383330975e-1,1.385961155208496420974841396949,-1.1750983631415945437001650354278]
[ .1845273287168265848989651+.518860744535330417140e-4*i,7.98128584415339900082029+.224420737255765751358e-2*i,-921.90365305631302770115467835537-2642.4306206792349087655207542102*i]]
[l,c]=size(date);
re=[];%存储结果
for p=1:l
if(isreal(date(p,:)) & (real(date(p,:))>0)/3)
re=[re ;date(p,:)];
end
end
re
假设你的结果是存在result里
result = result( isreal(result) & (result > 0) );
补充:
理解错了,你的解是一行,不是一个数
可以这样:
result = result(all(imag(result)==0, 2), :);
imag(result)==0 得到所有的实数
all(ima...
全部展开
假设你的结果是存在result里
result = result( isreal(result) & (result > 0) );
补充:
理解错了,你的解是一行,不是一个数
可以这样:
result = result(all(imag(result)==0, 2), :);
imag(result)==0 得到所有的实数
all(imag(result)==0, 2)得到列方向上全是实数的行
收起