Thread Subject:
Please correct this matlab code

Subject: Please correct this matlab code

From: fasd

Date: 6 Jul, 2012 08:59:10

Message: 1 of 22

 function [l,c,n] = find_edges(s , a, file)


 
fid = fopen(file, 'r') % fid = -1;
disp('found');
% msg = 'Failed to open specified input file';
%while fid < 0
    %disp(msg);
    %filename = input('Open file: ', 's');
    %[fid,msg] = fopen(filename);
%end
 
 

    seq_dur++ % end of test sequence gets full ms for execution

false(b);
t = 0;
last_t = 1.0 + act_off - seq_dur;
l = v1(3);
c = v2(3);
n = v3(3);
fread(fid, c, 16);
fread(fid, n, 16);
c(2) = mult;
n(2) = mult;



while ~feof(fid)

swap(l, c);
swap(c, n);
                fread(fid, n, 16)

                t = (unsigned(c(0)) mod seq_dur) - 1;
                n(2) = mult;

            
          if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0)

if(~b)
rel_delta = l(1) - last_t;
disp( l(1), ' ' , rel_delta , ' ', (t + (l(1) - unsigned(l(1)))) , ' ', l(2) , ' ');
last_t = l(1);
if(rel_delta > (seq_dur + 3.0) || rel_delta < (seq_dur - 1.0))
disp( 'bad delta ' , ' ', rel_delta ,sprintf('\n'));
if(~cont) break;
                    
                    end
                end
            end
         
true(b);
          end

          elseif(b && l(2) < 0.8 && c(2) < 0.5 && n(2) < 0.5)

disp( (t + (c(1) - unsigned(c(1)))) ,sprintf('\n'));
false(b);
              end

end
if(b)
disp( t ,sprintf('\n'));
    
    end
            

                    

Subject: Please correct this matlab code

From: Greg Heath

Date: 7 Jul, 2012 06:51:16

Message: 2 of 22

"fasd" wrote in message <jt69cu$kdu$1@newscl01ah.mathworks.com>...
> function [l,c,n] = find_edges(s , a, file)
>
>
>
> fid = fopen(file, 'r') % fid = -1;
> disp('found');
> % msg = 'Failed to open specified input file';
> %while fid < 0
> %disp(msg);
> %filename = input('Open file: ', 's');
> %[fid,msg] = fopen(filename);
> %end
>
>
>
> seq_dur++ % end of test sequence gets full ms for execution
>
> false(b);
> t = 0;
> last_t = 1.0 + act_off - seq_dur;
> l = v1(3);
> c = v2(3);
> n = v3(3);
> fread(fid, c, 16);
> fread(fid, n, 16);
> c(2) = mult;
> n(2) = mult;
>
>
>
> while ~feof(fid)
>
> swap(l, c);
> swap(c, n);
> fread(fid, n, 16)
>
> t = (unsigned(c(0)) mod seq_dur) - 1;
> n(2) = mult;
>
>
> if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0)
>
> if(~b)
> rel_delta = l(1) - last_t;
> disp( l(1), ' ' , rel_delta , ' ', (t + (l(1) - unsigned(l(1)))) , ' ', l(2) , ' ');
> last_t = l(1);
> if(rel_delta > (seq_dur + 3.0) || rel_delta < (seq_dur - 1.0))
> disp( 'bad delta ' , ' ', rel_delta ,sprintf('\n'));
> if(~cont) break;
>
> end
> end
> end
>
> true(b);
> end
>
> elseif(b && l(2) < 0.8 && c(2) < 0.5 && n(2) < 0.5)
>
> disp( (t + (c(1) - unsigned(c(1)))) ,sprintf('\n'));
> false(b);
> end
>
> end
> if(b)
> disp( t ,sprintf('\n'));
>
> end

What kind of error messages did you get when testing on a small toy problem?

Hope this helps.

Greg

Subject: Please correct this matlab code

From: fasd

Date: 9 Jul, 2012 08:53:07

Message: 3 of 22

 function [l,c,n] = find_edges(s , a, file)

fid = fopen(file, 'r');
disp('found');
    %frewind(fid);
    %A=fread(fid,'double');
   %length(A)
  % A(1:20)
     % assignin('base','helpme',A)
    %fread(fid,'double')
    %fread(fid,'double')
    %fread(fid,'double')
        

    v1 = [0 0 0];
    v2 = [0 0 0];
    v3 = [0 0 0];
  b = false;
    seq_dur=0;
    seq_dur = seq_dur + 1;

    act_off = 0;
  
last_t = 1 + act_off - seq_dur;
l = v1;
c = v2;
n = v3;
    frewind(fid);
C=fread(fid, 'double');
    length(C)
    C(1:50)
    assignin('base','helpme',C)
%N=fread(fid, 'double');
   %length(N)
   %N(1:20)
    %assignin('base','helpme',N)
%c(2) = mult;
%n(2) = mult;

while ~feof(fid)

swap(l, c);
swap(c, n);
                fread(fid, n, 16)

                t = mod(c(0), seq_dur) - 1;
                n(2) = mult;

            
          if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0)

if(~b)
rel_delta = l(1) - last_t;
disp( l(1), ' ' , rel_delta , ' ', (t + (l(1) - l(1))) , ' ', l(2) , ' ');
last_t = l(1);
if(rel_delta > (seq_dur + 3) || rel_delta < (seq_dur - 1))
disp( 'bad delta ');
                    disp( ' ');
                    disp( rel_delta );
                    disp( sprintf('\n'));
if(~cont)
                        break;
                    end
                end
            end
           
         
b = true;
          

          elseif(b && l(2) < 0.8 && c(2) < 0.5 && n(2) < 0.5)

disp(t + (c(1) - c(1)));
            disp(sprintf('\n'));
b = false;

          end

end


b = true;
t=2;
if(b)
disp(t)
        disp(sprintf('\n'))
    end
    
   
 end
                    




I corrected it, but still giving me : ans: 0 0 0
help me plz

Subject: Please correct this matlab code

From: Florian

Date: 9 Jul, 2012 09:20:07

Message: 4 of 22

Hi,

it is a little difficult to help you without knowing what the function should actually do. Can you please describe the input and output please?

Regards,
Florian

Subject: Please correct this matlab code

From: fasd

Date: 9 Jul, 2012 09:49:07

Message: 5 of 22

 function [l,c,n] = find_edges(s , a, file)

fid = fopen(file, 'r');
disp('found');
    %frewind(fid);
    %A=fread(fid,'double');
   %length(A)
  % A(1:20)
     % assignin('base','helpme',A)
    %fread(fid,'double')
    %fread(fid,'double')
    %fread(fid,'double')
        

    v1 = [0 0 0];
    v2 = [0 0 0];
    v3 = [0 0 0];
  b = false;
    seq_dur=0;
    seq_dur = seq_dur + 1;

    act_off = 0;
  
last_t = 1 + act_off - seq_dur;
l = v1;
c = v2;
n = v3;
    frewind(fid);

N=fread(fid, 'double');
   length(N)
   N(1:50)
    assignin('base','helpme',N)
%c(2) = mult;
%n(2) = mult;

while ~feof(fid)

swap(l, c);
swap(c, n);
                fread(fid, n, 16)

                t = mod(c(0), seq_dur) - 1;
                n(2) = mult;

            
          if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0)

if(~b)
rel_delta = l(1) - last_t;
disp( l(1), ' ' , rel_delta , ' ', (t + (l(1) - l(1))) , ' ', l(2) , ' ');
last_t = l(1);
if(rel_delta > (seq_dur + 3) || rel_delta < (seq_dur - 1))
disp( 'bad delta ');
                    disp( ' ');
                    disp( rel_delta );
                    disp( sprintf('\n'));
if(~cont)
                        break;
                    end
                end
            end
           
         
b = true;
          

          elseif(b && l(2) < 0.8 && c(2) < 0.5 && n(2) < 0.5)

disp(t + (c(1) - c(1)));
            disp(sprintf('\n'));
b = false;

          end

end


b = true;
t=2;
if(b)
disp(t)
        disp(sprintf('\n'))
    end
    
   
 end
                    



" I NEED TO FIND:
1- RISING EDGES ALONG WITH THEIR TIME.
2- BE ABLE TO READ DATA ..LINE BY LINE.

PLEASE HELP!
"

Subject: Please correct this matlab code

From: Florian

Date: 9 Jul, 2012 10:01:08

Message: 6 of 22

hmmm...look, your code to me is rather poorly formatted...personally I find it very hard to read it. Also the if statements in the if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0) were not closed properly, so I donÄt know whether your code actually ran at all! I've tried to format your code a little bit, but you definitely need to clean it up and do the statements properly. Alos get rid of everything thats not neede, otherwise its hard to see what you actually need:

function [l,c,n] = find_edges(s , a, file)

    fid = fopen(file, 'r');
    disp('found');

    v1 = [0 0 0];
    v2 = [0 0 0];
    v3 = [0 0 0];
    b = false;
    seq_dur=0;
    seq_dur = seq_dur + 1;

    act_off = 0;

    last_t = 1 + act_off - seq_dur;
    l = v1;
    c = v2;
    n = v3;
    frewind(fid);

    N=fread(fid, 'double');
    length(N)
    N(1:50)
    assignin('base','helpme',N)

    while ~feof(fid)

        swap(l, c);
        swap(c, n);
        fread(fid, n, 16)

        t = mod(c(0), seq_dur) - 1;
        n(2) = mult;


        if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0)

            if(~b)
                rel_delta = l(1) - last_t;
                disp( l(1), ' ' , rel_delta , ' ', (t + (l(1) - l(1))) , ' ', l(2) , ' ');
                last_t = l(1);
            end
            if(rel_delta > (seq_dur + 3) || rel_delta < (seq_dur - 1))
                disp( 'bad delta ');
                disp( ' ');
                disp( rel_delta );
                disp( sprintf('\n'));
            end
            if(~cont)
                break;
            end

            b = true;

            if(b && l(2) < 0.8 && c(2) < 0.5 && n(2) < 0.5)
                disp(t + (c(1) - c(1)));
                disp(sprintf('\n'));
                b = false;
            end

        end

    end


    b = true;
    t=2;
    if(b)
        disp(t)
     disp(sprintf('\n'))
    end

end

Subject: Please correct this matlab code

From: fasd

Date: 9 Jul, 2012 10:46:07

Message: 7 of 22

"Florian" wrote in message <jtea54$4g2$1@newscl01ah.mathworks.com>...
> hmmm...look, your code to me is rather poorly formatted...personally I find it very hard >to read it. Also the if statements in the if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > >1.0) were not closed properly, so I donÄt know whether your code actually ran at all! >I've tried to format your code a little bit, but you definitely need to clean it up and do >the statements properly. Alos get rid of everything thats not neede, otherwise its hard >to >see what you actually need:
>




MY CODE AIMS AT READING FROM A FILE LINE BY LINE, AND FINDING THE RISING EDGES ALONG WITH THEIR TIME.
I THINK I WROTE IT IN A GOOD WAY, BUT STILL GIVING ME BAD RESULT!!!!!!

Subject: Please correct this matlab code

From: dpb

Date: 9 Jul, 2012 12:34:52

Message: 8 of 22

On 7/9/2012 5:46 AM, fasd wrote:
> "Florian" wrote in message <jtea54$4g2$1@newscl01ah.mathworks.com>...
>> hmmm...look, your code to me is rather poorly formatted...personally I
>> find it very hard >to read it. Also the if statements in the if(~b &&
>> l(2) > 0.4 && c(2) > 0.9 && n(2) > >1.0) were not closed properly, so
>> I donÄt know whether your code actually ran at all! >I've tried to
>> format your code a little bit, but you definitely need to clean it up
>> and do >the statements properly. Alos get rid of everything thats not
>> neede, otherwise its hard >to >see what you actually need:
>>
...

> MY CODE AIMS AT READING FROM A FILE LINE BY LINE, AND FINDING THE RISING
> EDGES ALONG WITH THEIR TIME.
> I THINK I WROTE IT IN A GOOD WAY, BUT STILL GIVING ME BAD RESULT!!!!!!

DON"T SHOUT!!!!!

Well, your mission (should you choose to accept it) is now to learn to
use the debugger and figure out where (and then why) it isn't doing what
you expect.

There's absolutely no way anybody here can know what you expect the
results to be a priori.

Give either a _complete_ description of the input and expected output or
post a _VERY_ small sample dataset or way to create a test data set and
the results of that...

--

Subject: Please correct this matlab code

From: fasd

Date: 10 Jul, 2012 08:22:15

Message: 9 of 22

Am so confused, i have been trying to work on this type of code for 2 days,Nothing!!!

Ok can you make for me a code which:
1- extracts "fread" from a file named "output.dat", this file contains numbers only.
2- detects rising edges along with their times
3- displays rising edges and their times.

Subject: Please correct this matlab code

From: Barry Williams

Date: 10 Jul, 2012 10:13:07

Message: 10 of 22

"fasd" wrote in message <jtgonn$co$1@newscl01ah.mathworks.com>...
> Am so confused, i have been trying to work on this type of code for 2 days,Nothing!!!
>
> Ok can you make for me a code which:
> 1- extracts "fread" from a file named "output.dat", this file contains numbers only.
> 2- detects rising edges along with their times
> 3- displays rising edges and their times.

Multiple posters have responded to your pleas for help and have offered suggestions, but they have also explained repeatedly that it's very difficult to debug someone else's code without explaining the inputs and outputs and including comments explaining what the various lines of code are supposed to be doing.
As dpb suggested, do some debugging on your own first and examine your output at some breakpoints. We still really have no idea what your data look like. A 'rising edge' can be detected by several means. As suggested, the simplest method is to use the diff function.
Other possibilities: (1) If you have some idea of the underlying function that describes the data, you can fit your data and calculate a differential. (2) If the data are noisy, you could try smoothing. (3) Interpolation may be needed if the data interval is not adequate. (4) And in the end, as noted, if you still need more help, you need to provide a small dataset for others to work with.
Barry

Subject: Please correct this matlab code

From: fasd

Date: 10 Jul, 2012 10:48:08

Message: 11 of 22

My supervisor who gave me this task went on a travel for 1 week and he doesn't check his email, i was only given this C++ and asked to transform into matlab:


// actual program

std::ifstream file;
file.open(filename.c_str(), std::ios::in | std::ios::binary);
if(!file)
{
std::cerr << get_appname(argv[0]) << ": Failed to open specified input file" << std::endl;
return EXIT_FAILURE;
}
seq_dur++; // end of test sequence gets full ms for execution
double v1[2], v2[2], v3[2];
bool b = false;
unsigned t = 0;
double last_t = 1.0 + act_off - seq_dur;
double* l = v1;
double* c = v2;
double* n = v3;
file.read((char*)c, 16);
file.read((char*)n, 16);
c[1] *= mult;
n[1] *= mult;
while(file)
{
std::swap(l, c);
std::swap(c, n);
file.read((char*)n, 16);
n[1] *= mult;
t = (unsigned(c[0]) % seq_dur) - 1;
if(!b && l[1] > 0.4 && c[1] > 0.9 && n[1] > 1.0)
{
if(!b)
{
double rel_delta = l[0] - last_t;
std::cout << std::fixed << l[0] << " " << rel_delta << " " << (t + (l[0] - unsigned(l[0]))) << " " << l[1] << " ";
last_t = l[0];
if(rel_delta > (seq_dur + 3.0) || rel_delta < (seq_dur - 1.0))
{
std::cerr << "bad delta " << std::fixed << rel_delta << std::endl;
if(!cont) break;
}
}
b = true;
}
else if(b && l[1] < 0.8 && c[1] < 0.5 && n[1] < 0.5)
{
std::cout << (t + (c[0] - unsigned(c[0]))) << std::endl;
b = false;
}
}
if(b) std::cout << t << std::endl;
return EXIT_SUCCESS;
}

Subject: Please correct this matlab code

From: dpb

Date: 10 Jul, 2012 13:28:32

Message: 12 of 22

On 7/10/2012 5:48 AM, fasd wrote:
> My supervisor who gave me this task went on a travel for 1 week and he
> doesn't check his email, i was only given this C++ and asked to
> transform into matlab:
>
...

Well, how much simpler it would have been if you had started there... :(

I don't read C++ so I'm outta' here, though...

I'll comment though before retiring from the field that to make
progress you need to read that code and figure out the underlying
algorithm first, then implement that algorithm in Matlab rather than try
to translate C++ to Matlab--the languages are vastly different in what
(or more accurately, probably, how) they do what they do well.

In Matlab, generally things work better if you can use the inherent
builtin array and matrix functions to do things rather than looping on
an element-by-element basis as this code does. Unless the datafiles are
extremely large, memory should be no issue.

--

Subject: Please correct this matlab code

From: dpb

Date: 10 Jul, 2012 14:08:04

Message: 13 of 22

On 7/10/2012 5:48 AM, fasd wrote:
> My supervisor who gave me this task went on a travel for 1 week and he
> doesn't check his email, i was only given this C++ and asked to
> transform into matlab:
...
>
> std::ifstream file;
> file.open(filename.c_str(), std::ios::in | std::ios::binary);
> if(!file)
> {
> std::cerr << get_appname(argv[0]) << ": Failed to open specified input
> file" << std::endl;
> return EXIT_FAILURE;
> }
...
> double v1[2], v2[2], v3[2];

...

OK, I can decipher enough to see that it is, indeed, a stream file of
doubles--that's definitely progress.

To read it in Matlab use the first form outline above...the equivalent
of the above plus returning a vector (assuming and I think I can read
enough to understand it's what it is) of the file content is--

filename=input('Enter file: ',s);
[fid,mess]=fopen(filename,'r');
if fid<0, error(mess),end % except system-specific failure msg

x=fread(fid,inf,'double');

fid=fclose(fid); % we're done w/ the file so close it

...

Now do what you need about the algorithm

--

Subject: Please correct this matlab code

From: dpb

Date: 10 Jul, 2012 16:40:12

Message: 14 of 22

On 7/10/2012 9:08 AM, dpb wrote:
> On 7/10/2012 5:48 AM, fasd wrote:
>> My supervisor who gave me this task went on a travel for 1 week and he
>> doesn't check his email, i was only given this C++ and asked to
>> transform into matlab:
> ....
>>
>> std::ifstream file;
>> file.open(filename.c_str(), std::ios::in | std::ios::binary);
>> if(!file)
>> {
>> std::cerr << get_appname(argv[0]) << ": Failed to open specified input
>> file" << std::endl;
>> return EXIT_FAILURE;
>> }
> ....
>> double v1[2], v2[2], v3[2];
>
> ....
>
> OK, I can decipher enough to see that it is, indeed, a stream file of
> doubles--that's definitely progress.

Well, check that--I just looked at the following declaration and
presumed because of it the file was doubles...unfortunately, it ain't
so... :(

 > double v1[2], v2[2], v3[2];
...
 > double* l = v1;
 > double* c = v2;
 > double* n = v3;
 > file.read((char*)c, 16);
 > file.read((char*)n, 16);
 > c[1] *= mult;
 > n[1] *= mult;
 > while(file)
 > {
 > std::swap(l, c);
 > std::swap(c, n);
 > file.read((char*)n, 16);
 > n[1] *= mult;

This is some sort of non-IEEE format from some instrument I'd guess--I
don't read C/C++ well enough otomh to decipher what the above is doing
well enough to tell what the format is w/o _way_ more effort than I'm
willing to invest w/ no information on from where the data came as bread
crumbs through the forest...

But the upshot is, what I gave before has no chance, sorry...

You need to find the documentation for the device or the program or
whatever is the data source and go back to ground zero here and figure
out what it is that you've been handed.

--

Subject: Please correct this matlab code

From: dpb

Date: 10 Jul, 2012 17:51:18

Message: 15 of 22

On 7/10/2012 11:40 AM, dpb wrote:
...

> You need to find the documentation for the device or the program or
> whatever is the data source...

Or, post back what it is that the data comes from; maybe there's
somebody here who has the same device or data source and has dealt with
it...

Now are you beginning to see the importance of telling "the whole
story"??? :)

--

Subject: Please correct this matlab code

From: dpb

Date: 11 Jul, 2012 18:48:50

Message: 16 of 22

On 7/10/2012 11:40 AM, dpb wrote:
...

> But the upshot is, what I gave before has no chance, sorry...
...

Well, I should have known better than to presume I could decipher C++ --
the arcaneness of it all never cease to boggle me mind. :(

On looking up the .read method, I see it is only defined for char()
buffer, apparently so the cast to a double is required to use it.

So, I'll recast my opinion back to that of the example earlier of
opening the file and using

x=fread(fid,inf,'double');

should, I think, actually result in x being useful data.

I'd suggest testing this at the command window and seeing if the result
on a data file does, in fact, look reasonable. I may see if I can dig
through what the next stuff is actually doing but no promises of

a) actually spending any great amount of time doing so any time "real
soon now", or

b) getting it right if do... :)

--

Subject: Please correct this matlab code

From: dpb

Date: 12 Jul, 2012 19:36:19

Message: 17 of 22

On 7/11/2012 1:48 PM, dpb wrote:
> On 7/10/2012 11:40 AM, dpb wrote:
> ....
>
>> But the upshot is, what I gave before has no chance, sorry...
> ....
>
> Well, I should have known better than to presume I could decipher C++ --
> the arcaneness of it all never cease to boggle me mind. :(
>
> On looking up the .read method, I see it is only defined for char()
> buffer, apparently so the cast to a double is required to use it.
>
> So, I'll recast my opinion back to that of the example earlier of
> opening the file and using
>
> x=fread(fid,inf,'double');
>
> should, I think, actually result in x being useful data.
>
> I'd suggest testing this at the command window and seeing if the result
> on a data file does, in fact, look reasonable. I may see if I can dig
> through what the next stuff is actually doing but no promises of
>
> a) actually spending any great amount of time doing so any time "real
> soon now", or
>
> b) getting it right if do... :)

Well, I'm stuck w/o far more C++ than I want to take the time to learn...

I don't grok the

     c[1] *= mult;

and similar--I _presume_ mult is a macro or something similar from some
include or a method library but a search couldn't find such an animal
not knowing precisely what I was looking for...

My only suggestion at this point is either one of three or a combination
thereof--

a) find somebody like your prof that can tell you what the code is
actually doing numerically/algebraically and forget the C++ and just
code that in Matlab then verify the results or

b) find somebody who knows enough C++ to be able to do the above from
the code itself, or

c) take a dataset and the debugger and the C++ manual/documentation for
the local compiler and walk through it until you can grok what's
happening yourself.

I have no C++ compiler installed (and am not going to have--like the AAA
commercial I've seen on TV of the lady who says she's never changed a
tire in her life and at her age she sees zero chance of it happening
now--that's where I am w/ C++ :) ) so I've pretty much reached end of
any chance of doing you any good unless you go path a) and have some
specific Matlab questions re: "how to implement operation XXX?"

Good luck...

--

Subject: Please correct this matlab code

From: Steven_Lord

Date: 12 Jul, 2012 20:50:32

Message: 18 of 22



"dpb" <none@non.net> wrote in message news:jtn8vo$hk9$1@speranza.aioe.org...

*snip*

> My only suggestion at this point is either one of three or a combination
> thereof--

Option d), if the OP just needs to run this code inside MATLAB not convert
it into MATLAB code, would be to create a C++ MEX-file.

To the original poster, if that's something in which you'd be interested,
look in the External Interfaces chapter in the User's Guide part of the
documentation for MATLAB.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Please correct this matlab code

From: dpb

Date: 12 Jul, 2012 22:27:32

Message: 19 of 22

On 7/12/2012 3:50 PM, Steven_Lord wrote:
...

> Option d), if the OP just needs to run this code inside MATLAB not
> convert it into MATLAB code, would be to create a C++ MEX-file.
>
> To the original poster, if that's something in which you'd be
> interested, look in the External Interfaces chapter in the User's Guide
> part of the documentation for MATLAB.

Yeah, that'd probably work if the prof were to be satisfied...and if
it's hidden/wrapped in a call, who's to tell him different? :)

--

Subject: Please correct this matlab code

From: dpb

Date: 13 Jul, 2012 16:11:38

Message: 20 of 22

On 7/12/2012 3:50 PM, Steven_Lord wrote:
>
>
> "dpb" <none@non.net> wrote in message
> news:jtn8vo$hk9$1@speranza.aioe.org...
>
> *snip*
>
>> My only suggestion at this point is either one of three or a
>> combination thereof--
>
> Option d), if the OP just needs to run this code inside MATLAB not
> convert it into MATLAB code, would be to create a C++ MEX-file.
...

I did some more searching for "mult" at MSDN on the assumption it's the
MS compiler and came up empty on anything that seemed remotely like what
this code would be...

I do hope OP will eventually report back (but am not holding breath
waiting) on what this piece of code actually does or somebody who does
know enough C++ to be able to decipher stumbles over it and comments...

I'm at the point of "inquiring minds" and all that... :)

--

Subject: Please correct this matlab code

From: fasd

Date: 16 Jul, 2012 09:48:07

Message: 21 of 22

Hate coding

Subject: Please correct this matlab code

From: dpb

Date: 16 Jul, 2012 15:56:51

Message: 22 of 22

On 7/16/2012 4:48 AM, fasd wrote:
> Hate coding

:)

Are we to infer we're not having fun yet? :)

Have you a definition of how the algorithm works yet?

Did you try the suggestion of opening the file and reading one or more
doubles w/ fread() and seeing if those are, indeed, meaningful floating
point values? (Despite my earlier conclusion thinking it was/is some
non-IEEE instrument format or similar, after looking more I think it is
reading doubles

fid=fopen('yourfile','r');
if fid>0,
x=fread(fid,inf,'double');
end

Is there some other set of include files or additional source or
something besides the code you posted that contains a definition of
'mult' that's used in the following amongst other places--

c[1] *= mult;

?? It would seem the whole algorithm starts from there...but there's no
definition for mult in the code listing you've supplied and I found no
references to anything presuming a MS compiler that seemed of any
bearing at MSDN and other MS support sites.

--

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
file fasd 10 Jul, 2012 06:49:13
matlab fasd 10 Jul, 2012 06:49:13
c fasd 10 Jul, 2012 06:49:13
rising edge fasd 9 Jul, 2012 05:49:11
fread fasd 9 Jul, 2012 05:49:11
line by line fasd 9 Jul, 2012 05:49:11
elseif fasd 6 Jul, 2012 05:04:12
matlab code fasd 6 Jul, 2012 05:04:12
if fasd 6 Jul, 2012 05:04:12
rssFeed for this Thread

Contact us