How to solve and store a system of non-linear equations with an array of outputs?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a system where I have two equations and two unknowns shown below. The unkowns are dRF and dLF and I want to solve for dRF and dLF for each value of davg. I plan on keeping Ap constant to avoid some complexity for now, but eventually would want to find a way to where I can treat both Ap and davg as independent variables by setting a range of values for them and seeing what values for dRF and dLF are produced. So my first thought was to use linsolve, however since these equations aren't linear, after some research I found that vpasolve would help with this situation. Using vpasolve, I was able to get an output for dRF and dLF when using a single value for Ap and davg, however the outputs for dLF and dRF are extremely large, even though computationally when plugged back in, they produce the correct Ap and davg, but in reality these values for dLF and dRF should be b/w 0 to 45 deg since they are what make up davg. However, I found that when adding 180 to dRF and subtracting 180 from dLF, the values are much more logical and subbing them back into the equations, everything checks out.
So then when I wanted to see what dLF and dRF would be depending on davg, putting an array for davg resulted in an error saying "More equations than variables is only supported for polynomial systems.", so at this point I'm kinda stuck on where to go about this. Do I have to do a for loop potentially to account for the changing value for davg? Because I know that If I change the value for davg one by one instead of setting it up as an array, I get different outputs. I tried a for loop seen in the batch of code below, which did produce different values for dLF and dRF, which is great however I can't store these results in an array for dLF and dRF seperately, which is an issue. I also want to find a way to take these stored values and add 180 to dRF and subtract 180 from dLF for better presentation. Would very much appreciate any assistance with this, especially if there's another method that's a bit more intuitive than vpasolve. Fsolve didn't work out well for me with the guesses you have to put in, so vpasolve at least gets me accurate-ish results, but has its issues with storing and outputting obnoxious angle representations instead of something b/w 0 to 90 deg.
clear; clc;
Ap= 1.5;
davg= (linspace(0,30,100));
%davg= 30; % Test with one value
w= 52;
L= 60;
syms dRF dLF
for i= 1:length(davg)
eq1=(cotd(dRF)-cotd(dLF))/(w/L)== Ap;
eq2=acotd((cotd(dRF)+cotd(dLF))/2)==davg(i);
sol= vpasolve([eq1, eq2],[dRF,dLF])
end
^ Output when using 30 deg. for davg. Like I said, computationally it makes sense, but these values should really be between 0 to 45 deg, which they happen to be when adding 180 to dRF and subtracting 180 from dLF.
0 件のコメント
採用された回答
Torsten
2022 年 6 月 16 日
編集済み: Torsten
2022 年 6 月 16 日
Taking cotd on both sides of the second equation gives
cotd(dRF)-cotd(dLF)=Ap*w/L;
cotd(dRF)+cotd(dLF)=2*cotd(davg(i));
Thus
cotd(dRF) = (Ap*w/L+2*cotd(davg(i)))/2
cotd(dLF) = (2*cotd(davg(i))-Ap*w/L)/2
Thus
dRF = acotd( (Ap*w7L+2*cotd(davg(i)))/2 )
dLF = acotd( (2*cotd(davg(i))-Ap*w/L)/2 )
No need to use solve or vpasolve.
4 件のコメント
Torsten
2022 年 6 月 16 日
w= 52;
L= 60;
n = 20;
davg= linspace(0,30,n);
Ap= linspace(0,1,n).';
dRF = acotd( (Ap*w/L+2*cotd(davg))/2 )
dLF = acotd( (2*cotd(davg)-Ap*w/L)/2 )
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!