Matlab to C converting problems

This is a discussion on Matlab to C converting problems within the C Programming forums, part of the General Programming Boards category; Hello! I have a little problem I'm completely new to C. I'm trying to translate a matlab program to C ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    4

    Matlab to C converting problems

    Hello!

    I have a little problem I'm completely new to C. I'm trying to translate a matlab program to C and having some problems.

    Firstly I have a while loop where the exit requirements is that a a difference between temperature between two iterations must be smaller the a set error.
    In matlab I do like this:

    Code:
    T_capt_out=[];
    n_iter=0;
    E=100;
    while E>0.0001
    
    n_iter=n_iter+1;
    
    calculating temp code...
    
    T_capt_out(n_iter)=T_calc
    
        if length(T_capt_out)>1
             E=abs(T_capt_out(end)-T_capt_out(end-1));
        end
    end
    How would i implement this in C since I can't make T_capt_out=[] array that I just fill up?

  2. #2
    msh
    msh is offline
    Novice
    Join Date
    Jul 2009
    Posts
    568
    [Redacted on second thought]

    Consider allocating and extending the array dynamically, as you go. Look up malloca() and realloc().
    Last edited by msh; 05-11-2010 at 03:28 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 09-20-2009, 07:39 AM
  2. Convert Matlab Algebraic Sol to C compatible
    By Takeshi in forum C Programming
    Replies: 3
    Last Post: 01-08-2009, 05:35 PM
  3. MATLAB importing C libraries
    By chico1st in forum C Programming
    Replies: 1
    Last Post: 05-29-2008, 02:01 PM
  4. C/C++ and Matlab?
    By darkwalk in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2006, 03:00 AM
  5. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21