矩阵计算vb.net 矩阵计算器
vb.net中矩阵计算问题请教高手.
给你一个函数 Public Sub Vect1XtoVect2(ByVal x1 As Double, ByVal y1 As Double, ByVal z1 As Double, _ ByVal x2 As Double, ByVal y2 As Double, ByVal z2 As Double, _ ByRef xNew As Double, ByRef yNew As Double, ByRef zNew As Double) '矢量叉积 xNew = y1 * z2 - z1 * y2 yNew = z1 * x2 - x1 * z2 zNew = x1 * y2 - y1 * x2 End Sub其中x1,y1,z1为第一个矢量,x2,y2,z2为第二个矢量xnew,ynew,znew为得到的新矢量
创新互联是一家专业提供杭锦后企业网站建设,专注与成都网站建设、成都网站制作、HTML5、小程序制作等业务。10年已为杭锦后众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。
求助,初学者想问VB.NET,怎么输入一维列矩阵或者一维行矩阵怎么转置成一维列矩阵?谢谢了!
在程序设计语言里,用二维数组来保存矩阵的值。
一维列矩阵,就是由:若干行、一列组成的二维数组。
一维行矩阵,就是由:一行、若干列组成的二维数组。
比如一维列矩阵,的输入:
dim a(10,1) as integer '10行,1列
dim i as integer
for i = 1 to 10
a(i,1) = inputbox("")
next i
求助!用Vb.net编写两个矩阵相乘!
Public Shared Sub Main()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Console.WriteLine("该程序将求出两个矩阵的积:")
Console.WriteLine("请指定矩阵A的行数:")
a = Integer.Parse(Console.ReadLine())
Console.WriteLine("请指定矩阵A的列数:")
b = Integer.Parse(Console.ReadLine())
Dim MatrixA As Integer(,) = New Integer(a - 1, b - 1) {}
For i As Integer = 0 To a - 1
For j As Integer = 0 To b - 1
Console.WriteLine("请输入矩阵A第{0}行第{1}列的值:", i + 1, j + 1)
MatrixA(i, j) = Integer.Parse(Console.ReadLine())
Next
Next
Console.WriteLine("矩阵A输入完毕.")
Console.WriteLine("请指定矩阵B的行数:")
c = Integer.Parse(Console.ReadLine())
Console.WriteLine("请指定矩阵B的列数:")
d = Integer.Parse(Console.ReadLine())
Dim MatrixB As Integer(,) = New Integer(c - 1, d - 1) {}
For i As Integer = 0 To c - 1
For j As Integer = 0 To d - 1
Console.WriteLine("请输入矩阵A第{0}行第{1}列的值:", i + 1, j + 1)
MatrixB(i, j) = Integer.Parse(Console.ReadLine())
Next
Next
Console.WriteLine("矩阵B输入完毕.")
Console.WriteLine("矩阵A为:")
outputMatrix(MatrixA, a, b)
Console.WriteLine("矩阵B为:")
outputMatrix(MatrixB, c, d)
If b c Then
Console.WriteLine("矩阵A的列数与矩阵B的行数不相等,无法进行乘积运算!")
Return
Else
Console.WriteLine("矩阵A与矩阵B的乘积为:")
End If
Dim MatrixC As Integer(,) = New Integer(a - 1, d - 1) {}
For i As Integer = 0 To a - 1
For j As Integer = 0 To d - 1
MatrixC(i, j) = 0
For k As Integer = 0 To b - 1
MatrixC(i, j) += MatrixA(i, k) * MatrixB(k, j)
Next
Next
Next
outputMatrix(MatrixC, a, d)
End Sub
Private Shared Sub outputMatrix(MatrixX As Integer(,), rowCount As Integer, columnCount As Integer)
For i As Integer = 0 To rowCount - 1
For j As Integer = 0 To columnCount - 1
Console.Write(MatrixX(i, j) vbTab)
Next
Console.WriteLine()
Next
End Sub
End Class
vb.net 数组显示矩阵的一道题
'这是在vb6中的代码,在vb.net中基本差不多,你可以参考一下
Private Sub cmdCommand1_Click()
Me.AutoRedraw = True
Dim Grp
Grp = Array(1, 2, 3, 4, 5)
Dim i, j As Long
Dim StrPrt As String
For i = 0 To UBound(Grp)
'i为位移量
StrPrt = ""
For j = i To UBound(Grp)
StrPrt = StrPrt Grp(j)
Next j
For j = 0 To i - 1
StrPrt = StrPrt Grp(j)
Next j
Me.Print StrPrt
Next i
End Sub
用vb.net编程,建立一个m行n列的矩阵,找出其中最小的元素所在的行和列,并输出该值及其行、列位置
没错!!
你的算法是:
1.定义三个变量,minValue(放最小值),X(放最小值的X坐标),Y(放最小值的Y坐标)。
2.遍历矩阵。在遍历过程中将最小值放在minValue中,最小值的X坐标放在X中,最小值的Y坐标放在X中。
在vb中,关于矩阵赋值和计算的问题
Private Sub Command1_Click()
Dim i As Integer
Dim px(0 To 136) As Double
Dim py(0 To 136) As Double
Dim pz(0 To 136) As Double
For i = 0 To 136 '生成随机模拟数据
px(i) = Int(Rnd * 1000)
py(i) = Int(Rnd * 1000)
pz(i) = Int(Rnd * 1000)
Next
For i = 0 To 135 '按矩阵结构分布的数据;
Debug.Print px(i + 1) - px(i), 0, py(i) - py(i + 1)
Debug.Print py(i + 1) - py(i), 0, px(i + 1) - px(i)
Debug.Print pz(i + 1) - pz(i), -1, 0
Debug.Print "---------------------------------------"
Next
End Sub
以下是运行后的部分示例结果:希望对你有帮助
---------------------------------------
-68 0 419
-419 0 -68
-61 -1 0
---------------------------------------
-301 0 -667
667 0 -301
-235 -1 0
---------------------------------------
212 0 597
-597 0 212
-17 -1 0
---------------------------------------
-460 0 270
-270 0 -460
328 -1 0
---------------------------------------
774 0 -465
465 0 774
62 -1 0
---------------------------------------
13 0 325
-325 0 13
-116 -1 0
---------------------------------------
-577 0 -64
64 0 -577
125 -1 0
---------------------------------------
-257 0 -236
236 0 -257
462 -1 0
---------------------------------------
419 0 -392
392 0 419
-308 -1 0
---------------------------------------
-116 0 217
-217 0 -116
-593 -1 0
---------------------------------------
315 0 -8
8 0 315
433 -1 0
---------------------------------------
-601 0 477
-477 0 -601
-171 -1 0
---------------------------------------
629 0 173
-173 0 629
192 -1 0
---------------------------------------
-27 0 -750
750 0 -27
-193 -1 0
---------------------------------------
215 0 -4
4 0 215
349 -1 0
---------------------------------------
-67 0 -71
71 0 -67
-258 -1 0
---------------------------------------
-782 0 -79
79 0 -782
381 -1 0
---------------------------------------
573 0 553
-553 0 573
-781 -1 0
---------------------------------------
-529 0 237
-237 0 -529
493 -1 0
---------------------------------------
239 0 58
-58 0 239
-233 -1 0
---------------------------------------
237 0 -743
743 0 237
221 -1 0
---------------------------------------
-456 0 -47
47 0 -456
-125 -1 0
---------------------------------------
136 0 126
-126 0 136
-154 -1 0
---------------------------------------
123 0 534
-534 0 123
660 -1 0
---------------------------------------
164 0 -138
138 0 164
-489 -1 0
---------------------------------------
250 0 -211
211 0 250
542 -1 0
---------------------------------------
-343 0 255
-255 0 -343
-63 -1 0
---------------------------------------
-258 0 71
-71 0 -258
-690 -1 0
---------------------------------------
87 0 257
-257 0 87
564 -1 0
---------------------------------------
494 0 -276
276 0 494
-40 -1 0
---------------------------------------
-436 0 -533
533 0 -436
39 -1 0
---------------------------------------
33 0 734
-734 0 33
-331 -1 0
---------------------------------------
-98 0 -633
633 0 -98
-98 -1 0
---------------------------------------
459 0 559
-559 0 459
280 -1 0
---------------------------------------
158 0 -92
92 0 158
347 -1 0
---------------------------------------
-842 0 -741
741 0 -842
-307 -1 0
---------------------------------------
484 0 82
-82 0 484
-58 -1 0
---------------------------------------
-353 0 42
-42 0 -353
-500 -1 0
---------------------------------------
193 0 101
-101 0 193
171 -1 0
---------------------------------------
-60 0 362
-362 0 -60
281 -1 0
---------------------------------------
-108 0 -184
184 0 -108
-317 -1 0
---------------------------------------
-192 0 -314
314 0 -192
-98 -1 0
---------------------------------------
574 0 -5
5 0 574
120 -1 0
---------------------------------------
297 0 54
-54 0 297
210 -1 0
---------------------------------------
-457 0 77
-77 0 -457
393 -1 0
---------------------------------------
-110 0 574
-574 0 -110
-508 -1 0
---------------------------------------
31 0 43
-43 0 31
293 -1 0
---------------------------------------
-314 0 -53
53 0 -314
73 -1 0
---------------------------------------
405 0 22
-22 0 405
299 -1 0
---------------------------------------
分享文章:矩阵计算vb.net 矩阵计算器
标题路径:http://myzitong.com/article/hepedj.html