From: skyworld on
On Jul 9, 9:12 am, skyworld <chenyong20...(a)gmail.com> wrote:
> On Jul 8, 11:17 pm, "Jan Simon" <matlab.THIS_Y...(a)nMINUSsimon.de>
> wrote:
>
> > Dear Yong,
>
> > >     double  tmp_x[DATA_NUM];
> > >         tmp_x[i] = 12;
> > >         mexPrintf("tmp_x=%d\n",tmp_x[i]);
>
> > Your tmp_x is a double vector. Display doubles with the format "%f" or "%g", because "%d" formats integers.
>
> > Please post just the relevant part of the code and omit all lines, which are not involved in the runtime error.
>
> > Good luck, Jan
>
> Hi Jan,
>
> thanks for your kind information. You just point out one of my errors.
> Thanks. A very annoying problem is that when I revised %d to %f, there
> is no messages on command window output. When I change back to %d,
> also no output. totally different from yesterday. That is my life....
>
> regards
> yong

Hi Jan,

I found the reason and now I can display right data. thanks for your
help.


regards
From: skyworld on
On Jul 9, 9:22 am, skyworld <chenyong20...(a)gmail.com> wrote:
> On Jul 9, 2:35 am, "James Tursa"
>
>
>
>
>
> <aclassyguy_with_a_k_not_...(a)hotmail.com> wrote:
> > skyworld<chenyong20...(a)gmail.com> wrote in message <9eb6e874-c2c3-4de1-ad17-446a3c028...(a)k8g2000prh.googlegroups.com>...
>
> > > I wrote a mex file like this:
>
> >     (snip)
>
> > > It is very interesting that I can't get right data from x_data,
> > > coef_data and tmp_x. The display shows these data are very huge
> > > numbers, which I think should be within +/- 4. And sometime when I run
> > > the m file, the matlab will report run-time error. Could anybody help
> > > me to find what is wrong with this code? thanks.
>
> > You are probably exceeding valid indexes for the arrays. Impossible to tell for sure because you didn't post enough information about size of the inputs. e.g., I would suspect this line:
>
> > >             y_data_array[i] += x_data[i+j]*coef_data[COEF_NUM-j-1];
>
> > Does x_data really contain 511+6+1 = 518 elements?
>
> > Try putting in some checks to see that your sizes and indexing are all consistent.
>
> > James Tursa
>
> Hi James,
>
> thanks for your message. In fact I'm trying to write a code for FIR
> check so that it could be used in HW co-simulation. My inputs to this
> function are two arguments: x_data with 512 samples and coefficients
> with 7 taps. In order to match matlab filter outputs, I guess I need
> to pad 6 zeros before x samples. That is the reason I defined tmp_x.
> My purpose would like to do this:
>      for (i=0 to i=5) tmp_x(i) = 0;
>      for (i=6 to i=518) tmp_x(i) = x_data(i-6);
>  then I will do fir multiply-addition as
>      y_data_array[i] += x_data[i+j]*coef_data[COEF_NUM-j-1];
>
> I met two problems when doing above:
> 1) I can't get right data in tmp_x from x_data. I use code like these
> to check if tmp_x got data from x_data
>    for (i=0;i<DATA_NUM;i++)
>     {
>         tmp_x[i] = 12;
>         mexPrintf("tmp_x=%d\n",tmp_x[i]);
>         tmp_x[i] = x_data[i];
>         mexPrintf("i=%d, x=%d, tmp_x=%d\n",i,x_data[i],tmp_x[i]);
>     }
> the display shows two data are different.
>
> 2) If I use only 512 x sample to do fir calculation, the result seems
> ok. But if I run this program several times, there maybe run-time
> error. I don't know what kind of hidden issues in my code.
>
> thanks.- Hide quoted text -
>
> - Show quoted text -

Hi James,

I solved it. Thanks for your help very much.


regards