PDA

View Full Version : how to change a particular line of code in a m file


matlab4t
23 Feb 2008, 07:21pm
hi ,

i need to change a single line of code in my file with another line. can anyone suggest a way to do it

JB
23 Feb 2008, 08:23pm
Using Linux?

sed -e 's/old line/new line/'

shwaip
23 Feb 2008, 08:40pm
iirc, you're doing this to a python script. Make the thing you need to change a command line argument to the script.

matlab4t
23 Feb 2008, 09:57pm
Using Linux?

sed -e 's/old line/new line/'

hi

i am trying to change a line in the .m file which is read by matlab

JB
23 Feb 2008, 10:05pm
I'm confused. Is this the same problem that you describe here: http://icrontic.com/forum/showthread.php?t=69489?

If not, why don't you just go into the file and change the line you want to modify?

shwaip
23 Feb 2008, 11:31pm
he wants to be able to change it automagically based on some calculated value.

he shouldn't be doing it this way, though. It should be a parameter/argument to the .py script, or he should rewrite the .m file so it's a function rather than a script.

JB
24 Feb 2008, 01:32am
he shouldn't be doing it this way, though. It should be a parameter/argument to the .py script, or he should rewrite the .m file so it's a function rather than a script.

Agreed.