Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Calling another file to Interpolate from an Array ...

Calling another file to Interpolate from an Array ...

Calling another file to Interpolate from an Array ...

Hello all,

I'm in the process of translating some old C++ code into Matlab in order to make my matrix and vector operations easier. I am still fairly novice with Matlab, so I've come upon a problem that I am not sure can be done the way I imagine it should work. My goal is to interpolate through a x-y matrix that is contained in a seperate .m file from my code.

I am trying to lay out my logic in this way for my program:
- Here is some input (including x, y, and the array name).
- Call File2 that contains the actual routine to interpolate in an array.
- Call File3 that holds my arrays.
- Find the array that I have specified.
- Interpolate from this array, given my inputs.
- Return the value to me.

My sticking point is trying to load the file that contians all of my arrays (I have many), where one array can be picked out and used.

Has anyone else done something similar to this before? I am not entirely sure how to work around this problem. I have sucessfully made a test interpolation from a small table, using interp1 with a .mat file, but I had to strip all of the headings and comments out of my array. I didn't want to do this with my actual data.

Thanks in advance for your thoughts!

RE: Calling another file to Interpolate from an Array ...

Look up matlab 'functions"
You can create your own.
For example, your interp. could send and give back the value in one line.
[xi,yi]=interp(x,y), where interp.m is the function you created.  


RE: Calling another file to Interpolate from an Array ...

You might like to consider the implications of "assignin".

Alternatively the following bit of code shows me asking the user to enter a search string and then copying the first variable of that name into c1. Trouble is that eval allows you to do things that are infinitely naughty.
uiload;%loads a file with several arrays into workspace
who%lists them all
si=input('enter search term, with wildcards ','s');
eval (['who ',si])%lists the ones its found
s=who(si);%creates a string of the variable names

    eval(['c1=',s1,';']); %copies that array into c1

I'm not saying the above is the correct way to do it. But it works.

So far as reading dirty files, yes there are some rather impenetrable commands that as a C++ programmer you will enjoy. Anyway read the Help on Importing and Exporting Data. Personally I make my users give me clean data, or at least structured data.



Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies  http://eng-tips.com/market.cfm?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close