Advertisement
Guest User

Untitled

a guest
May 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. clc; clear all
  2. vector13 = [1/3 2.1 3.1];
  3. vector31 = [1 2 3]';
  4. matrix33 = [11 12 13;...
  5. 21 22 23;...
  6. 31 32 33];
  7. scalar = 3;
  8. % Create a text file containing workspace variables.
  9. varNames = who; %List of variable names in workspace in alphabetical order.
  10. fileName = 'workspace.txt';
  11. delete(fileName);
  12.  
  13. fid = fopen(fileName, 'a');
  14. for i=1:length(varNames)
  15. sizeOfVar = size(eval(char(varNames(i))));
  16. fprintf(fid, '%s : %s = ', char(varNames(i)), num2str(sizeOfVar, '%d, %d'));
  17. valStr = num2str(eval(char(varNames(i))),'%1.15f ');
  18. for iRow = 1:sizeOfVar(1)
  19. fprintf(fid, '%s ', valStr(iRow,:));
  20. end
  21. fprintf(fid, '\n');
  22. end
  23. fclose(fid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement