我正在尝试用C语言编写MATLAB转义函数。到目前为止,我有这个:
int n=Length(SignalArray);
int m=Length(FilterArray);
TempX=[SignalArray,Zeros(1,FilterArray)];
TempH=[FilterArray,Zeros(1,SignalArray)];
for(int i=0;i<n+m-1;i++){
ResultArray(i)=0;
for(int j=0;j<=m-1;j++){
if(i-j+1>0){
int TempVal=ResultArray(i)+TempX(j)*TempH(i-j);
ResultArray(i)=TempVal;
}
}
}
卷积结果的第一个元素很好但是最后一个元素要么是正确的,要么显示为一个非常高的数字(类似于10的幂9)。
请帮忙。
答案 0 :(得分:1)
好。所以我使用了以下函数(其中函数AddAtSpecificIndex具有原型AddAtSpecificIndex(Array,Value,Index)):
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) 'Handles RadGrid1.NeedDataSource
Dim RadGrid1 As RadGrid = CType(Page.FindControl("RadGrid1"), RadGrid)
RadGrid1.DataSource = GetDataTable("SELECT کالا.شناسه, کالا.عنوان, کالا.پوشه, بارگیری, کالا.گروه_شناسه, گروه.عنوان AS گروه FROM کالا LEFT JOIN گروه ON کالا.گروه_شناسه = گروه.شناسه")
End Sub
Public Function GetDataTable(ByVal query As String) As DataTable
Dim ConnString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Dim conn As SqlConnection = New SqlConnection(ConnString)
Dim adapter As SqlDataAdapter = New SqlDataAdapter
adapter.SelectCommand = New SqlCommand(query, conn)
Dim table1 As New DataTable
conn.Open()
Try
adapter.Fill(table1)
Finally
conn.Close()
End Try
Return table1
End Function