Thread: Help needed

  1. #16
    Registered User
    Join Date
    Feb 2013
    Posts
    12
    Quote Originally Posted by Click_here View Post
    Do not put ';' in the first line.
    Without ';'

    Code:
    Error PV_module_wrapper.c: 70  syntax error; found `{' expecting `;' 
    Error PV_module_wrapper.c: 70  skipping `{' 
    Error PV_module_wrapper.c: 76  undeclared identifier `I' 
    Error PV_module_wrapper.c: 76  type error: pointer expected 
    Warning PV_module_wrapper.c: 76   possible usage of I before definition 
    Error PV_module_wrapper.c: 81  unrecognized declaration 
    5 errors, 1 warnings 
     
      C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Compile of 'PV_module_wrapper.c' failed.
    What might the problem now?
    The last error is because it skipped '{'
    but for undeclared identifier 'I' and pointer expected error I don't know..
    And the syntax error of coarse.. ???
    Last edited by Prefas; 02-18-2013 at 06:23 PM.

  2. #17
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Another suggestion> Why don't you start with the simplest possible function before adding something complicated. Since you seem to be using a custom build environment like Matlab. You should first make a "Hello Matlab" function to get a hold of the basics of what this environment expects.

  3. #18
    Registered User
    Join Date
    Feb 2013
    Posts
    12
    Quote Originally Posted by c99tutorial View Post
    Another suggestion> Why don't you start with the simplest possible function before adding something complicated. Since you seem to be using a custom build environment like Matlab. You should first make a "Hello Matlab" function to get a hold of the basics of what this environment expects.
    It doesn't change anything if you change the math function. If you solve one error you solve every error of this kind. And if I use a simple function I can't find out what is needed for my problem..
    For example if I had 1 parameter I would have the same error as with 10 parameters. But with 10 parameters you will need 10 corrections which are the same

  4. #19
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by Prefas View Post
    if I use a simple function I can't find out what is needed for my problem..
    It's hard to tell that without trying a simple function. Your problem could be something else entirely.

    Just make a simple function called timestwo(x) for example that returns the value 2x. If you can't even get such a simple function to work in Matlab, then clearly something is wrong. That's the suggestion.

    If, on the other hand, a simple function DOES work, then you simply have to introduce incremental changes to the simple function which bring the simple function closer and closer to the definition of your complicated function. Then you can see exactly what goes wrong.

  5. #20
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Is the c compiler LCC?

    Double check this for me


    Go to MATLAB prompt and type:


    mex -setup


    and make sure that LCC is chosen
    Fact - Beethoven wrote his first symphony in C

  6. #21
    Registered User
    Join Date
    Feb 2013
    Posts
    12
    yes, c compiler is LCC
    thank you for your help..!

  7. #22
    Registered User
    Join Date
    Feb 2013
    Posts
    12
    A lot of the errors are fixed..
    This is the current status

    Code:
    void Sigma(const real_T *Tc,const real_T *Irradiance,const real_T *Vpv,const real_T *I, real_T *Ipv)
    {
        real_T Irs, Is, J, Tcc;
        (I[0] < 0) ? (J=0) : (J = I[0]);
        Tcc = (Tc[0]) + 273.15; /* Celsius to Kelvin Trasformation*/
        Irs = (IscRef[0]) / (exp((q[0]) * ((VocRef[0]) + (beta[0]) *((Tcc)-(Tref[0]))) / ((Ns[0]) * (K[0]) * (eta[0]) * (Tcc))) -1);
        Is = (Irs) * (pow(Tcc/Tref[0], 3)) * exp( (q[0]) * (Eg[0]) * (1/(Tref[0]) - 1/(Tcc))/((K[0]) * (eta[0])));
        Ipv[0] = (Np[0]) * ((((alpha[0]) * ((Tcc) - (Tref[0])) + (IscRef[0])) * (Irradiance[0])/(Irradiance_ref[0])) -
                ((Is) * (exp((q[0]) * ((Vpv[0])/(Ns[0]) + (J) * (Rs[0])/(Np[0])) / ((K[0]) * (Tcc) * (eta[0]))) -1) +
                ((Np[0])/(Ns[0]) * (Vpv[0]) + (J) * (Rs[0])) / (Rsh[0])));
    }
    Builder Info:
    Code:
    Error PV_module_wrapper.c: 71  syntax error; found `{' expecting `;' 
    Error PV_module_wrapper.c: 71  skipping `{' 
    Error PV_module_wrapper.c: 82  unrecognized declaration 
    3 errors, 0 warnings 
     
      C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Compile of 'PV_module_wrapper.c' failed.
    Any ideas?

  8. #23
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by Prefas View Post
    It is a C function builder and you provide the c code for the output (the above code) separately from the parameters
    Quote Originally Posted by Prefas View Post
    the part before this subroutine is automatically generated by matlab including initializing, calling methods and terminate.
    I only have to write the mdlOutput subroutine
    Quote Originally Posted by Prefas View Post
    I use this type of block
    S-Function Builder Dialog Box - MATLAB & Simulink

    And the code goes at the "outputs pane" section
    Code:
    void Sigma(const real_T *Tc,const real_T *Irradiance,const real_T *Vpv,const real_T *I, real_T *Ipv)
    {
    Code:
    Error PV_module_wrapper.c: 71  syntax error; found `{' expecting `;'
    Are you sure that you have to write the function header? After reading through the link you've posted I think you only have to write the function body. So try to get rid of the first line and the curly braces.

    Bye, Andreas

  9. #24
    Registered User
    Join Date
    Feb 2013
    Posts
    12
    Andreas, thank you. It finally compiled without errors with your advice and some other changes.
    But I'm disappointed because this doesn't seem to bypass the algebraic loop I was trying to avoid with this function..
    Anyway thank you all for your help!
    Peace and laugh

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Needed
    By tvenki in forum C Programming
    Replies: 2
    Last Post: 08-13-2003, 03:18 AM
  2. Help needed.
    By saravanan_ts in forum Windows Programming
    Replies: 7
    Last Post: 08-06-2003, 09:18 AM
  3. Help Needed...
    By Akaii in forum C Programming
    Replies: 4
    Last Post: 08-02-2003, 11:45 PM
  4. Help needed
    By nightingale in forum C Programming
    Replies: 10
    Last Post: 07-15-2003, 01:20 AM
  5. Help Needed
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 06-14-2002, 01:38 PM

Tags for this Thread