- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的问题是如何将这些方程写成数组并求解?
from scipy import linalg
import numpy as np
import matplotlib.pyplot as plt
x = np.array[-23,1100,2300],[2300,1500,550],[550,1600,]
我尝试在上面的数组中写入,但我不知道如何替换问题中的“In”和“Vs2”。你能帮我解决这个问题吗?
最佳答案
您想要针对多个电压求解这些方程,这建议使用 for
循环。为了清楚起见,通常最好使用值标识符,例如,使用 R1
而不是 1100。将 R1
放入公式中,让计算机为您执行简单的算术运算。
您可能正在考虑使用 linalgsolve
函数,因为您需要求解三阶方阵。未知数就是潮流。因此,进行代数运算,以便获得矩阵系数以及方程右侧以电阻和电压表示的表达式。
对于矩阵(如 https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.solve.html#scipy.linalg.solve 文档中所示),
a = np.array([[f1(Rs, Vs), f2(Rs, Vs), f3(Rs, Vs)], [...], [...]])
对于右侧的向量,
b = np.array([f4(Rs, Vs), f5(Rs,Vs), f6(Rs, Vs)])
然后电流=求解(a, b)
请注意,f1、f2 等是您必须进行代数计算的函数。
现在将此代码放入循环中,或多或少像这样:
for vs2 in [10,15,20,25]:
currents = solve(a, b)
因为代数表达式中有电阻和 vs2,所以您将得到相应的电流。您需要收集与电压相对应的电流以进行绘图。
加法:代数运算的部分结果:
更多:我如何使用 sympy 库避免大多数讨厌的代数:
>>> R1, R2, R3, R4, R5, Vs1 = 1100, 2300, 1500, 550, 1600, 23
>>> from sympy import *
>>> var('I1,I2,I3,Vs2')
(I1, I2, I3, Vs2)
>>> eq1 = -Vs1 + R1*I1 + R2 * (I1-I2)
>>> eq1
3400*I1 - 2300*I2 - 23
>>> eq2 = R2*(I2-I1)+R3*I2+R4*(I2-I3)
>>> eq2
-2300*I1 + 4350*I2 - 550*I3
>>> eq3 = R4*(I3-I2)+R5*I3 + Vs2
>>> eq3
-550*I2 + 2150*I3 + Vs2
>>> from scipy import linalg
>>> import numpy as np
>>> for Vs2 in [10,15,20,25]:
... ls = np.array([[3400,-2300,0],[-2300,4350,-550],[0,-550,2150]])
... rs = np.array([23, 0, -Vs2])
... I = linalg.solve(ls, rs)
... Vs2, I
...
(10, array([ 0.01007914, 0.0048996 , -0.00339778]))
(15, array([ 0.00975305, 0.00441755, -0.00584667]))
(20, array([ 0.00942696, 0.0039355 , -0.00829557]))
(25, array([ 0.00910087, 0.00345346, -0.01074446]))
关于python - 使用SciPy的线性代数方法求解三个联立方程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59616659/
我开始测试 Haskell 的线性代数。有没有人为此目的提供最佳包装的建议?使用 Haskell 进行基本矩阵操作的任何其他好的资源? Haskell 维基 lists several resourc
对于给定的向量,我想找到它周围的正交基, 即给定向量归一化和随机选择的正交子空间的基础。 在 Julia 中有一个方便的功能吗? 最佳答案 您正在寻找的函数名为 nullspace . julia>
我想计算 Julia 1.0 中的经典伴随 为此,我复制了 wikipedia 中作为示例给出的矩阵 julia> B = [-3 2 -5; -1 0 -2; 3 -4 1] 3×3 Array{I
我最近开始阅读 OpenGL Superbible 第 5 版,并注意到以下内容: 刚刚学习了线性代数,这对我来说似乎很奇怪。列向量的尺寸为 4x1,矩阵的尺寸为 4x4,如何将它们相乘?如果向量是行
我正在尝试修改我的线性代数模块以避免虚拟 vtable 的东西.. 尝试使用 CRTP 和表达式模板。我选择了一些基本的东西来测试整个事情,但我无法让它工作。 我有 4 个类,比如:基 CRTP 类,
我对 C++ 和 OpenCV 很陌生,但对 Matlab 比较熟悉。我有一项任务需要转移到 C++ 以加快处理速度。所以我想就图像处理问题征求您的建议。我在一个文件夹中有 10 张图片,我可以使用
我有一个数组 w (shape (3000, 100, 100)) 我想将它与另一个数组 e (shape (5, 3000)) 使得结果 k 的形状为 (5, 5, 100, 100) 和 k[:,
Tally-ho 小伙子们, 这个问题认为线性代数的艺术是数学中我无法解决的地方。所以我希望你们能帮助我 :D。 我正在尝试为一款名为《骑马与砍杀》的游戏创建单人自动踢球作弊。这个 autokicke
我是一名优秀的程序员,十分优秀!