What is the best approach in editing script files with other script files ?
Mostrar comentarios más antiguos
Suppose I have this in a script(A) currently:
temp1 = 435;
variable4 = 99990;
something = 56;
Using another script(B) I want this output:
new = 145;
var = 776;
thing = 9;
I have a excel spreadsheet that that has 1 column of the old variable names from A and another column that contains the new varibale name and a 3rd column with the new values. I can already change the variable names, but how do I find and replace the old values with the new values? I was thinking about using a strfind to find where the '=' and find where ';' is and then grab everything in between and replace it, but i think that this isnt the best approach for something like this. Opinions?
1 comentario
Respuesta aceptada
Más respuestas (1)
Muthu Annamalai
el 14 de Ag. de 2015
Editada: Muthu Annamalai
el 14 de Ag. de 2015
@Rodriguez, and @Cedric I propose an alternative way to look at the question; it would be nice to have same script return different results based on some updates.
I wonder if the updates could come from a MAT file or a CSV file, like,
function data = script_fcn()
latest_data = load('fname.mat') %or csvread(...)
data_modified = process( data ) %some processing
data = data_modified.fieldx;
end
and ofcourse the user can update the MAT/CSV from another script.
1 comentario
Cedric
el 14 de Ag. de 2015
Ah yes, well I assumed that it was some sort of one-shot code refactoring operation. Otherwise I think that we can discourage the OP to perform this kind of operations on a regular basis.
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!