我在matlab中有一个代码,带有6个方程和6个变量的系统。我想使用命令vpasolve来解决方程式。 6个变量是t11,t12,t13,t21,t22,t23。
有没有办法为6个变量中的每一个定义解的范围?
例如,我想定义以下范围:
t11应介于10到50之间
t12应在20到40之间
t13应在10到50之间
t21应在-30到-10之间
t22应在-10到50之间
t23应该在-20到0之间
(以及任何超出范围的东西我都不想作为解决方案,即使它解决了这个等式)。
这里是我想解决的方程式的matlab代码:
clear;
close all;
clc;
syms t11 t12 t13
syms t21 t22 t23
eq1 = ((8922777075240195*t11)/9007199254740992 - 30)^2 + (96876011531181065287337706581037*t11^2)/5192296858534827628530496329220096 == (244*t21^2)/15869 + ((125*15869^(1/2)*t21)/15869 - 30)^2;
eq2 = (12284794394556242997808640319605*t12^2)/1298074214633706907132624082305024 + ((4482238245702333*t12)/4503599627370496 - 30)^2 == (244*t22^2)/15869 + ((125*15869^(1/2)*t22)/15869 - 30)^2;
eq3 = (45861658983305836864232546144709*t13^2)/2596148429267413814265248164610048 + ((1115910933745515*t13)/1125899906842624 - 30)^2 == (244*t23^2)/13469 + ((115*13469^(1/2)*t23)/13469 - 30)^2;
eq4 = ((8922777075240195*t11)/9007199254740992 - 30)*((4482238245702333*t12)/4503599627370496 - 30) - (33484849241113011368045542420311*t11*t12)/2596148429267413814265248164610048 == ((125*15869^(1/2)*t21)/15869 - 30)*((125*15869^(1/2)*t22)/15869 - 30) - (244*t21*t22)/15869;
eq5 = (282621115563350270054313878343*t12*t13)/2596148429267413814265248164610048 + ((1115910933745515*t13)/1125899906842624 - 30)*((4482238245702333*t12)/4503599627370496 - 30) == ((115*13469^(1/2)*t23)/13469 - 30)*((125*15869^(1/2)*t22)/15869 - 30) + (44*13469^(1/2)*15869^(1/2)*t22*t23)/213739561;
eq6 = ((8922777075240195*t11)/9007199254740992 - 30)*((1115910933745515*t13)/1125899906842624 - 30) - (23445242923211415885353539155021*t11*t13)/5192296858534827628530496329220096 == ((115*13469^(1/2)*t23)/13469 - 30)*((125*15869^(1/2)*t21)/15869 - 30) - (44*13469^(1/2)*15869^(1/2)*t21*t23)/213739561;
eqs = [eq1; eq2; eq3; eq4; eq5; eq6];
fprintf('Trying to solve the equations\n');
[t11_sol,t12_sol,t13_sol,t21_sol,t22_sol,t23_sol] = vpasolve(eqs,
[t11,t12,t13,t21,t22,t23])
fprintf('Finished solving the equations\n');
这些是目前的解决方案:
t11_sol =
0
24.829703667085709792452797768139
-1714.7919752112047717253468263447
28.624266796914077249128523842231
15.001105796927906039239701205905
29.182011950632532749236452699932
30.474785714576283734530215094123
28.923418651100014933562154455752
29.862424638395540307680704064753
t12_sol =
0
32.391753131232910196633469521587
354.90128086865450529250280412221
32.669637807428363812347415161745
42.313425265860487109475748241225
35.77251360055612460919268449666
24.416997056184413504762966564475
32.200102042415756894425066902384
32.737813080348733797113244812407
t13_sol =
0
35.119449427391259768874643471793
-552.15221602531564524976910795555
32.333805237521337277174927681791
30.505819079433077866776605761009
-15.526604986133423038105829796394
30.503860894429235257295153122852
31.531326069780238017082050501478
30.689747387623702773113477696365
t21_sol =
0
34.950843287328625731811203211087
1774.2801076016584748700502034002
27.7309163513567839404453632282
44.586181192433735979455732171841
31.568950443178384558598040442723
31.645983484625245618431014726401
31.66220406339283719149782231373
31.4930547899057272421770424957
t22_sol =
0
28.719384780320222581709652667396
-295.26692316474930126337699876656
31.376616953264529835893660973616
17.528200591527370984833306720326
24.321988649431180122662011217513
34.695990177726174534054308234555
30.175898983099840329616659669692
31.493054789906158785302579540812
t23_sol =
0
24.379180250934429179070181825563
611.61273095943007252746244555442
32.247827126007408413822564919395
30.163585843012112112236997181374
74.982989890274977913497773016932
29.293932179042561861772077117988
28.046073521931256411622489184559
29.014005238849959150140190833736
我在matlab文档中看到你可以添加一个范围,但我看到的是一个变量的方程式。我没有看到任何带有多个变量范围的方程式。如果可能的话,我也没有看到任何地方。
有人能告诉我如何为每个变量添加范围(如果可能的话)?
此外,给定代码为每个变量返回9个解决方案。每个变量都有默认范围吗?我怎么知道它可能错过哪些变量?有多少解决方案真的存在?有没有办法知道这个?
谢谢!
答案 0 :(得分:1)
根据vpasolve
的文档,您应该能够将变量范围指定为N×2矩阵,其中N是变量的数量:
如果init_guess是一个包含两列的矩阵,那么两个条目 行指定相应的搜索范围的边界 变量。要在搜索范围矩阵中指定起点, 将两列指定为起点值。
在你的情况下:
varLimits = [10 50; 20 40; 10 50; -30 -10; -10 50; -20 0];
[t11_sol,t12_sol,t13_sol,t21_sol,t22_sol,t23_sol] = vpasolve(eqs,...
[t11,t12,t13,t21,t22,t23], varLimits)