1

is there any way to set variable name MATLAB like this: dif(i is in loop)

d1f
d2f
d3f
.
.
dnf

I've tried dnum2str(i)f, but it doesn't work as I expected.

asys
  • 667
  • 5
  • 20
  • 1
    Please do not do this. Dynamic variable names are only going to leave you in a world of hurt. Use a more appropriate data structure such as a cell array or struct with dynamic field names – Suever Nov 15 '16 at 19:39
  • 1
    Sure! `d_f(1), d_f(2), d_f(3), ... d_f(n)`. – beaker Nov 15 '16 at 19:54
  • https://fr.mathworks.com/help/matlab/ref/eval.html but use a cell instead `df = {}; for i = 1:10 df{i} = zeros(1,i); end; df ` – reuns Nov 16 '16 at 03:57

0 Answers0