How to use one matlab program to create a new .m file and insert executable code into it which is from a separate file?
Show older comments
Hello, I am attempting to create a function which determines variable values at different points in various separate programs which have certain variable values change. My program currently creates cell arrays of all code that is run in the program prior to each 'point'; these cell arrays look like this:
{0×0 char }
{'structure.A = 2; % Details' }
{'structure.B = 3; % Details' }
{'structure.C = 4; % Details' }
How would I go about copying this cell array into a new program and then running the program? This is what I have so far:
TempFileDirectory = [pwd,'\TempFile.m'];
FID = fopen(TempFileDirectory,'w');
fprintf(FID, '%s', char(FullText(1:65,:)));
fclose(FID);
TempFile;
This, however, does not work properly; instead of copying the code over into the new temporary file just as it is in the original file, it merges all of the code into one line which (obviously) cannot be executed. What do I do to fix this?
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!