From: roya olyazadeh on

>
> from = cellstr(num2str(from,'x%d'));
>
When I use 'cellstr' ,It is helpful for me for my function

FX=cellstr(num2str(from,'x%d'));
FY=cellstr(num2str(from,'y%d'));
TX=cellstr(num2str(to,'x%d'));
TY=cellstr(num2str(to,'y%d'));


for i= 1 : nd
L0(i)=subs(L01,[a b c d ],[FX(i,1) FY(i,1) TX(i,1) TY(i,1)]);
end


FX=
'x1'
'x2'
'x3'
'x4'
'x5'
'x6'

But when I want to use this way for 'diff(function,x1'
an error occurred :

for i= 1 : ns
AA(i,1)= diff(L0(i),FX(i));
end

??? Error using ==> sym.diff
Do not recognize argument number 2.



do you know what is the problem ?


When I defined it like this
FX=[x1 x2 x3 x4 x5 x6 ]


There is no error for diff(L0(i),FX(i));
From: Walter Roberson on
roya olyazadeh wrote:

> FX=cellstr(num2str(from,'x%d'));
> FY=cellstr(num2str(from,'y%d'));
> TX=cellstr(num2str(to,'x%d'));
> TY=cellstr(num2str(to,'y%d'));

> But when I want to use this way for 'diff(function,x1' an error occurred :
> for i= 1 : ns
> AA(i,1)= diff(L0(i),FX(i)); end
>
> ??? Error using ==> sym.diff
> Do not recognize argument number 2.

FX is a cell array of text, not of symbols. FX(i) is going to be a 1x1
cell array containing a text string. The first thing that I would try
would be to pass FX{i} to diff() instead of FX(i) -- using the {} will
pass the string instead of the cell array.

If that doesn't work, then I would use syms() to get the symbolic
variable associated with the name. For example, as a quick hack,

AA(i,1) = diff(L0(i), syms(FX{i}));

There would be more efficient ways to do this, but it is 2:30 in the
morning here and I am too tired to look them up in the reference
material (I do not have the symbolic toolbox to test against.)