Save giving a mistake "Argument must contain a character vector"
Show older comments
I am trying to use the save command to save the end state of two matrix and a variable of my calculation and here is part of the code that is causing the problem
if(save_state==1)
fprintf('State being saved!\n');
base_name=save_base;
base_name=strcat(base_name,'-',int2str(new_nelectrons),'-end-');
DOS_file=strcat(base_name,'DOS.mat');
OCC_file=strcat(base_name,'OCC.mat');
e_file=strcat(base_name,'e_left.txt');
fprintf('Saving OCC file to name: %s. \n',OCC_file);
save(OCC_file,'newOccupCOs');
fprintf('Done!\n');
fprintf('Saving DOS file to name: %s. \n',DOS_file);
save(DOS_file,'DOS_new');
fprintf('Done!\n');
fprintf('Saving electrons file to name: %s. \n',e_file);
fprintf(f2,'%d',new_nelectrons);
fprintf('Done!\n')
fprintf('Save successful!\n');
end
And here is the output together with error message:
Saving OCC file to name: test-1782-end-OCC.mat.
Error using save
Argument must contain a character vector.
Error in raMOmovie_forGordon>reconstruct_targets (line 2245)
save(OCC_file,'newOccupCOs');
Error in raMOmovie_forGordon>raMOmovie_run (line 976)
[OccupCOs raMOs_H1s DOS_so_far
nelectrons_left]=reconstruct_targets(filename,templatefile,orblistW,H,
DOS_so_far, OccupCOs, COs, psi_target,video_file,movie_on,
nelectrons_left,
frame_stepsize,E_COlist,DOSparameters,scalefactor,Eshift,save_state,save_base);
Error in raMOmovie_forGordon (line 738)
raMOmovie_run(filename, templatefile, videofile, nions,
orblist_bytype, electron_counts, E_Fermi,
DOSparameters,scriptcodes,scriptfiles,scalefactor,state_loaded,loaded_OccupCOs,loaded_DOS_so_far,loaded_e_left,run_save_state,save_base);
I get that this error message usually means OCC_file is not a string but I think it apparently is in this case? Could anybody help?
4 Comments
Walter Roberson
on 5 Jul 2018
What is class(save_base) ?
Erdong Lu
on 5 Jul 2018
Walter Roberson
on 6 Jul 2018
Is save_base a string() object or is it a character vector? Because if it is a string object then you might just be using a release between the time that strings were introduced (R2016b) and when it became possible to pass a string to save() (which I seem to recall was R2017b, but I would need to cross-check that.)
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!