Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to select a cell from an array when this array is made of functions of a parameter?

2 visualizzazioni (ultimi 30 giorni)
Dear all,
Consider an array
A = [a(t) b(t) c(t)].';
I want to select b(t). However, when I enter "A(2)", MatLab returns
a(2)
b(2)
c(2)
instead of
b(t).
How could we select get b(t) in this case?
Thanks

Risposte (2)

Giorgos Papakonstantinou
Giorgos Papakonstantinou il 6 Giu 2015
You can do
A{2}
or
A{1,2}

Marlon Saveri Silva
Marlon Saveri Silva il 6 Giu 2015
Modificato: Marlon Saveri Silva il 6 Giu 2015
Thanks. But MatLab returns this error:
Error using symfun/subsref (line 143)
Cell indexing and structure indexing are not implemented for symbolic functions.
This is my code:
clear
clc
%%Parameters
l = 12;
h = 0.9;
%%Coord. Systems
syms Alpha(t) Beta(t) Gama(t)
S_1_0=[ 1 0 0 ; 0 cos(Alpha) sin(Alpha) ; 0 -sin(Alpha) cos(Alpha)];
S_2_1=[ cos(Beta) 0 -sin(Beta) ; 0 1 0 ; sin(Beta) 0 cos(Beta)];
S_3_2=[ cos(Gama) sin(Gama) 0 ; -sin(Gama) cos(Gama) 0 ; 0 0 1];
S_3_0=S_3_2*S_2_1*S_1_0
%%Position, Veloc, Acc...
rc=l.*[sin(Gama) -cos(Gama) 0].' + S_3_0*[0 0 h].';
vc=fulldiff(rc,t);
ac=fulldiff(vc,t);
ac_y=ac{2}

Questa domanda è chiusa.

Tag

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by