Click here to Skip to main content
16,005,206 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CFileDialog problem Pin
David Crow14-May-03 3:45
David Crow14-May-03 3:45 
GeneralRe: CFileDialog problem Pin
Anonymous14-May-03 3:51
Anonymous14-May-03 3:51 
GeneralRe: CFileDialog problem Pin
David Crow14-May-03 4:19
David Crow14-May-03 4:19 
GeneralRe: CFileDialog problem Pin
Anonymous14-May-03 5:53
Anonymous14-May-03 5:53 
GeneralRe: CFileDialog problem Pin
Amihai14-May-03 3:49
Amihai14-May-03 3:49 
GeneralRe: CFileDialog problem Pin
Anonymous14-May-03 3:55
Anonymous14-May-03 3:55 
GeneralRe: CFileDialog problem Pin
Anonymous14-May-03 4:11
Anonymous14-May-03 4:11 
Generallength of a vector Pin
flora_k14-May-03 3:29
flora_k14-May-03 3:29 
Hi,
How do i write a program that evaluate the length of a vector?
Because i have this piece of code and when i complie it i get plenty of errors
#include <stdio.h>
#include <math.h>

double tailing = 0;
double trl_values = 0;
double y_int_1 = 0;
int rest = 0;
double leading = 0;
double histogram_ram = 0;
double i_index;
double Trl_values;
double y_int = 0;

/*******************************************************************************************


Transfer function:
1
----------------
3.333e-005 s + 1


Transfer function:
0.1829 z + 0.11829
-----------------------
z - 0.6341

Sampling time: 1.9113e-008
********************************************************************************************/



unsigned char Slice_level(unsigned char x) // Function accessible only from this file
{
double b0=0.1829,b1=0.11829;
double a1= 0.6341;
double temp_x1,temp_x2;
double temp_y1;
unsigned char y;
int static xn_1;
int static yn_1,yn_2; // y(n-1)

temp_x1 = x * b0;
temp_x2 = xn_1* b1;

temp_y1 = yn_1 * a1;

y = temp_x1+ temp_x2 + temp_y1;

xn_1 = x;
yn_1 = y;

return y;

}

//main()

void SLFilter (long amount, unsigned char* pData)
{
long n;
unsigned char y;
for (n=0; n<amount; n++)
="" {
="" y="Slice_level(pData[n]);

" pdata[n]="y;
"
="" printf("%8d="" n",y);
="" }
}


="" *******************************************************************************************
="" this="" code="" shows="" the="" trl_values="" calculation.="" it="" is="" going="" to="" help="" determining="" histogram=""
********************************************************************************************=""


void="" trl_calculation(int="" amount,="" unsigned="" char*pdata)
{
="" long="" n;
="" for="" (int="" i="1;" <="amount;" i++)
="" if="" ((y_int_1)="" -="" 0)="" &="" (y_int=""> 0)
tailing = 1 - (y_int- pData[n])/(y_int - y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;

if ((y_int_1- pData[n] > 0)&(y_int- pData[n] < 0))
tailing = 1 - (y_int - pData[n])/(y_int - y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;

rest = rest + 1;

y_int_1 = y_int;

}
}



void histogram(int amount, unsigned char*pData)
{
const double Duration = amount/4096;
for (int i=1; i <= amount; i++)
{
i_index = ceil(Trl_values(i)/Duration)+1;
histogram_ram(i_index)=histogram_ram(i_index)+1;

}
}

It looks like i am mixing up functions and variables.
May be i should create sub programs to carry out the task?
help with this code plz.
I provide the matlab code i want to translate into C as well

function trl_calculation
Trl_values = 0;
y_int_1 = 0;
rest = 0;
leading = 0;


Dura=10000/4096;%x ns per byte=total 1000ns / 4096 bytes.


read_data10
sl= 53.9998;
%lpfmodel_1st
%sl=lpfmodel_1st(t,y);
%sl=sl(k);

for i = 1:length(y)
y_int = y(i);
% Trl_function;
if ((y_int_1-sl<0)&(y_int-sl>0))
tailing = 1 - (y_int-sl)/(y_int-y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;
else if ((y_int_1-sl>0)&(y_int-sl<0))
tailing = 1 - (y_int-sl)/(y_int-y_int_1);
Trl_values(length(Trl_values)+1) = tailing + leading + rest;
leading = 1 - tailing;
rest = 0;
else
rest = rest + 1;
end;
end;

% As mentioned above, for example, y_int_1 is initial sample;
% y_int is next sample.
y_int_1 = y_int;
tailing
leading
rest
end;

histogram_ram(1:4096) = 0;

for i=1:length(Trl_values)
i_index=round(Trl_values(i)/Dura)+1;
histogram_ram(i_index)=histogram_ram(i_index)+1;

end;

plot(histogram_ram)


hx

F.K
GeneralRe: length of a vector Pin
Nick Parker14-May-03 3:50
protectorNick Parker14-May-03 3:50 
GeneralRe: length of a vector Pin
Nitron14-May-03 14:34
Nitron14-May-03 14:34 
GeneralRe: length of a vector Pin
Nick Parker15-May-03 18:25
protectorNick Parker15-May-03 18:25 
QuestionCan not get current time. Pin
George214-May-03 2:24
George214-May-03 2:24 
AnswerRe: Can not get current time. Pin
David Crow14-May-03 2:51
David Crow14-May-03 2:51 
GeneralRe: Can not get current time. Pin
George214-May-03 3:04
George214-May-03 3:04 
GeneralRe: Can not get current time. Pin
David Crow14-May-03 3:11
David Crow14-May-03 3:11 
GeneralRe: Can not get current time. Pin
George214-May-03 4:06
George214-May-03 4:06 
AnswerRe: Can not get current time. Pin
jhaga14-May-03 2:54
professionaljhaga14-May-03 2:54 
GeneralRe: Can not get current time. Pin
George214-May-03 3:02
George214-May-03 3:02 
GeneralRe: Can not get current time. Pin
jhaga14-May-03 3:08
professionaljhaga14-May-03 3:08 
GeneralRe: Can not get current time. Pin
George214-May-03 4:03
George214-May-03 4:03 
GeneralRe: Can not get current time. Pin
David Crow14-May-03 4:39
David Crow14-May-03 4:39 
GeneralRe: Can not get current time. Pin
George214-May-03 18:31
George214-May-03 18:31 
GeneralRe: Can not get current time. Pin
David Crow15-May-03 2:43
David Crow15-May-03 2:43 
GeneralRe: Can not get current time. Pin
George215-May-03 18:58
George215-May-03 18:58 
GeneralRe: Can not get current time. Pin
David Crow16-May-03 4:24
David Crow16-May-03 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.