MATLAB: Create workspace file automatically. workspace Let's say I have: a = {'one' 'two' 'three'}; b = [1 2 3]; I want each word create a file in workspace automatically and equal to number. Like: one=1; two=2; three=3; Best Answer I think you mean "variable," not "file." Right?for ii = 1:numel(a)eval(sprintf('%s = %d',a{ii},b(ii)));endCheers,Brett Related SolutionsMATLAB: How to dynamically assign data to a variable Dynamic and variable should really never be in the same sentence :)http://www.mathworks.com/matlabcentral/answers/57445-faq-how-can-i-create-variables-a1-a2-a10-in-a-loop MATLAB: X-label additional text automatically. Try something like this: x = 1:10;y = randn(1,10);figureplot(x,y)xlabel('Frequency [Hz]')text(max(xlim), min(ylim)-diff(ylim)*0.1, '(a)', 'HorizontalAlignment','right', 'VerticalAlignment','middle')It seems to work correctly in my simulations, and appears to produce constant relative positioning of ‘(a)’. Related QuestionHelp with dynamic variable names set with ‘for’ incrementerHow to create and save a variable that contains filenameGet same column of matrix automatically.Is it possible to do a for loop of this codeHow do i use the values read by the eval function in other formulas
Best Answer