convert cell to vector that contains a function
Afficher commentaires plus anciens
hello,
i´m about to write a script that automatically computes some differential operatores for a given coordinate system.
" clear;
syms r phi z;
%Dimension N of coordinate system
N = 3;
x = cell(1,N);
x{1} = r * cos(phi);
x{2} = r * sin(phi);
x{3} = z;
%new variables
y(1) = r;
y(2) = phi;
y(3) = z;
%tangential vectors ta
for i = 1:1:N
for j = 1:1:N
ta{i,j} = diff(x{i},y(j));
end
end
%show content
celldisp(ta);
"
now i want to save the content of ta{:,1} into a vector tmp and than compute the 2-norm of this vector...
i already tried something like this: "
tmp = ta{1,:};
b{1} = Norm(tmp,2);
"
but with this i get the following error " Undefined function 'Norm' for input arguments of type 'sym'."
thanks a lot for your time thanks for your time
Réponses (1)
Andrei Bobrov
le 14 Oct 2014
syms r phi z;
x = [r * cos(phi); r * sin(phi); z];
%new variables
y = [r; phi; z];
ta = jacobian(x,y);
b0 = arrayfun(@(ii)norm(ta(ii,:)),(1:size(ta,1))','un',0);
b = cat(1,b0{:});
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!