2 ty9413 ty9413 于 2016.05.02 15:03 提问

求VB大神帮助,想求一个公式的最大值,最小值,及对应的角度 5C

θ=输入值

S= 输入值

x=0 to 360
e=0.2S
h=1.2S
a=0.7S
X1=a*sin(θ+x)
y1=-a*cos(θ+x)
x2=e
y2=h+S
b= Math.Sqrt((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
求b的最大值bmax及对应的角度(x值),最小值bmin和最小值的角度(x值)
θ 和S 文本输入框让用户自定义

我用的是VB.NET
想要lable输出这样的结果,
最大值1234, 角度123
最小值123,角度12

1个回答

ty9413
ty9413   2016.05.02 15:16

vb.NET软件
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Me.TextBox1.Text = "" Then
MsgBox("请输入值", , "提示信息")
Else
Dim l1 As Double 'CB
Dim l2 As Double 'AB
Dim S As Double '从动杆工作行程
Dim a As Double '原动杆0A长度
Dim θ0 As Double '曲柄起始角度
'Dim Q1 As Double '升程运动对应的曲柄转角
' Dim Q2 As Double '最高位置停留对应的曲柄转角
'Dim Q3 As Double '降程运动对应的曲柄转角
'Dim Q4 As Double '最低位置停留对应的曲柄转角
Dim h As Double '滑块最低点到凸轮中心
Dim Ee As Double
Dim XB As Double
Dim XB1 As Double
Dim YB As Double
Dim XD As Double
Dim YD As Double
Dim x As Double
Dim max As Double
Dim min As Double
Dim J As Integer
Dim K As Double
Dim u As Double
Dim v As Double
Dim i As Double
Dim θ(0 To 360) As Double
For x = 1 To 360

            S = Me.TextBox1.Text
            a = S * 0.7             '曲柄AB
            h = S * 1.2
            Ee = Me.TextBox3.Text
            θ0 = Me.TextBox4.Text
            XB = a * Math.Sin(θ0 + x)
            YB = -a * Math.Cos(θ0 + x)
            XD = Ee
            YD = h + S
            θ(x) = Math.Sqrt((XB - XD) ^ 2 + (YB - YD) ^ 2)
        Next x
        For i = 2 To 360
            If θ(i) > max Then max = θ(i)
            K = YB
            J = XB


        Next i
        u = Math.Asin(J / a) * (360 / (2 * Math.PI))

        For x = 1 To 360

            S = Me.TextBox1.Text
            a = S * 0.7             '曲柄AB
            h = S * 1.2
            Ee = Me.TextBox3.Text
            θ0 = Me.TextBox4.Text
            XB1 = a * Math.Sin(θ0 + x)
            YB = -a * Math.Cos(θ0 + x)
            XD = Ee
            YD = h + S
            θ(x) = Math.Sqrt((XB1 - XD) ^ 2 + (YB - YD) ^ 2)
        Next x
        min = θ(1)

        For i = 2 To 360
            If θ(i) < min Then min = θ(i)

        Next i

        'Q1 = Me.TextBox5.Text
        'Q2 = Me.TextBox6.Text
        ' Q3 = Me.TextBox7.Text
        'Q4 = Me.TextBox8.Text
        l1 = (max + min) / 2
        l2 = (max - min) / 2

        v = Math.Asin(0.5) * (360 / (2 * Math.PI))

        Me.Label6.Text = "铰销D至轴的最小距离=" & h
        Me.Label7.Text = "曲柄AB=" & a
        Me.Label8.Text = "曲柄起始角度=" & θ0
        Me.Label9.Text = "偏心距离=" & Ee
        Me.Label10.Text = "fmax=" & Format(max, "##.00")
        Me.Label11.Text = "fmin=" & Format(min, "##.00")
        Me.Label12.Text = "杆CD=" & Format(l1, "##.00")
        Me.Label17.Text = "杆AB=" & Format(l2, "##.00")
        Me.Label18.Text = "度" & u& v


    End If

End Sub

    我自己弄的,但是值不对
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
求一组数中的最大值和最小值(VB6.0代码)
求一组数中的最大值和最小值,并有载入功能,注:可以把数据存入记事本,数据间用英文逗号分开。<br><br>并命名为Q.txt放在E盘根目录(E:\\Q.txt),然后点击“载入”。<br>QQ223857666勾月
求二维数组中的最大值 最小值及其下标
/* *程序的版权和版本声明部分: *Copyright(c)2013,烟台大学计算机学院学生 *All rights reserved. *文件名称: *作者:尚振伟 *完成日期:2013年 12月19日 *版本号:v0.1
汇编程序 求数组元素的最大值和最小值
汇编程序 求数组元素的最大值和最小值汇编程序 求数组元素的最大值和最小值汇编程序 求数组元素的最大值和最小值
vb.net 2010下求最大值、最小值及两种排序方法
算法:最大值,最小值及位置   Dim A%() = {8, 6, 9, 3, 2, 7}         Dim intMin%, intPos%, i%         intMin = A(0)   ‘最小值’         intPos = 0     ‘位置’         For i = 1 To 5             If A(i)            
用递归的方法求数组中元素的最大值和最小值
// 计算浮点数组最大值和最小值float CXXXDlg::Max(float x, float y){ if ( x > y ) {  return x; } else  {  return y; }}float CXXXDlg::ArrayMax(float a[], int n){ float maxa; if ( n==1 )  {  return Max( a[0], a[1] )
定义一个2维数组3行4列,求数组平均值最大值最小值js
function shuzu(arr){  var sum=0;   for(var i=0;i { for(var j=0;j { sum+=arr[i][j]; } } var avg=sum/12; alert('平均值'+avg); } function max(arr){ var max=arr[0][0] for(var i=0;i { for(var
java之数组求最大值与最小值
public class test6{ public static void main(String[] args){ //定义一个数组 int[] array={2,4,234,24,91,45}; int maxvalue=maxvalue(array); System.out.println("最大值是:"+maxvalue); } //定义一个选举最大值得方法
vb随机生成十个数并求出最大值
Private Function max(a() As Integer) As Integer Dim i As Integer Dim maxa As Integer For i = LBound(a) To UBound(a) If a(i) > maxa Then maxa = a(i) max = maxa End If Next i End Function Priv
sql server求分组最大值,最小值,最大值对应时间,和最小值对应时间
先创建Students表CREATE TABLE [dbo].[Students]([Id] [int] IDENTITY(1,1) NOT NULL,[age] [int] NULL,[name] [nvarchar](50) NULL,[addTime] [datetime]  NULL) ON [PRIMARY] 插入几条测试数据INSERT [dbo].[Students] ([age],...
NumPy常用函数(5)-- 寻找最大值和最小值,以及计算数组的取值范围
    通常,我们不仅想知道一组数据的平均值,还希望知道数据的极值以及完整的取值范围——最大值和最小值。    Numpy中min函数和max函数可以计算出最小值和最大值;ptp函数可以计算数组的取值范围,即该函数返回的是数组元素的最大值和最小值直接的差值(max(array) - min(array))。    最大值/最小值和取值范围实例:from numpy import * h,l=lo...