value from string ?
Mostrar comentarios más antiguos
I would like to use vectarrow function to draw vectors:
The code below defines a function fx for the x and y coordinates (x1 x2 x3 ...) of the vectors. I am confused how to get back the numerical values of fx and fy (instead of 'x1' -> 2, 'x2' -> 4...).
x1 = 2; x2 = 4; x3 = 5; x4 = 7;
y1 = 2; y2 = 4; y3 = 5; y4 = 7;
v= [1 2 3 4]; % the order changes
vv = length(v);
fx = cell(vv, 1);
for i=1:vv
fx{i} = strcat('x', num2str(v(i)));
fy{i} = strcat('y', num2str(v(i)));
end
%plot
for j = 1:length(v)-1
vectarrow([char(fx(j)); char(fy(j))], [char(fx(j+1)); char(fy(j+1))]); % does not work
hold on
end
hold off
3 comentarios
KSSV
el 1 de Ag. de 2017
The function accepts numbers/ double as input..you are not using it properly..
@Ole: all of the vectarrow examples show it being call with numeric inputs arguments. Why are you calling vectarrow with character input arguments?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!