Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I read part of a file and edit it in a matlab script?

Status
Not open for further replies.

unclethommy

Mechanical
Dec 12, 2006
1
Hi there I am using a custom-made Matlab s-function script which demands that I know how large my output data is before I intialise it. The problem is I want this to be chosen by a variable rather than me having to manually open the file and change it.

What I need to know is how to go about running an .m script file which does the following:

open another .m file

looked down to the n-th line of this file

replace the first number it finds on this line with one from a variable i choose

save and close the file ready to be run



I want this to be done all within matlab so i can simply run a script to do this.

Would anyone know how I can go about doing this? perhaps a suggestions of a command for each of the steps I need?

I have read into textread but that seems to want to read each word on the line into a seperate variable. Even then, I cant figure out how to write the new value back to the .m file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor