How to use one matlab program to create a new .m file and insert executable code into it which is from a separate file?
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!