Discussion:
()-indexing must appear last in an index expression
(too old to reply)
Bob
2011-10-01 17:05:31 UTC
Permalink
Hi guys!

-------------------------------------------------------------------------
[time,z]=ode45(@myode,[0 2],z0,options);

for i=time
X_traj=X_traj+z(:,1)(i)*cos(z(:,2)(i)+beta_zero);
end
------------------------------------------------------------------------

where is the mistake? from ode45 I get a matrix with four columns, and I want to do some operation until the integration time runs out.. any idea?

thanks in advance :)
Matt J
2011-10-01 18:00:28 UTC
Permalink
Post by Bob
where is the mistake? from ode45 I get a matrix with four columns, and I want to do some operation until the integration time runs out.. any idea?
===============

What's this expression supposed to mean: z(:,1)(i) ?

In any case, it's prohibited, as shown more simply in the following
Post by Bob
z(2,2)=5
z =

0 0
0 5
Post by Bob
z(:,1)(1)=0
??? Error: ()-indexing must appear last in an index expression.
Bob
2011-10-01 18:39:13 UTC
Permalink
Post by Matt J
Post by Bob
where is the mistake? from ode45 I get a matrix with four columns, and I want to do some operation until the integration time runs out.. any idea?
===============
What's this expression supposed to mean: z(:,1)(i) ?
In any case, it's prohibited, as shown more simply in the following
Post by Bob
z(2,2)=5
z =
0 0
0 5
Post by Bob
z(:,1)(1)=0
??? Error: ()-indexing must appear last in an index expression.
Ergo?
For example, my ode gives me 4 outputs for every istant:


t1-----a1- b1-c1-d1
t2-----a2-b2-c2-d2
.
.
.
tN----aN-bN-cN-dN

I want to:
X1=X0+a1*b1
X2=X1+a2*b2
.
.
XN=X(N-1)+aN*bN

and then to plot X(i)..

How can do this using "for"?
I hope it's clear what I would get!
Matt J
2011-10-01 20:31:11 UTC
Permalink
Post by Bob
X1=X0+a1*b1
X2=X1+a2*b2
.
.
XN=X(N-1)+aN*bN
and then to plot X(i)..
How can do this using "for"?
==============



X=zeros(N+1,1);
X(1)=X0;

for i=1:N
X(i+1)=X(i)+a(i)*b(i)
end

X(1)=[];

plot(t,X)
Bob
2011-10-02 19:00:29 UTC
Permalink
Post by Matt J
Post by Bob
X1=X0+a1*b1
X2=X1+a2*b2
.
.
XN=X(N-1)+aN*bN
and then to plot X(i)..
How can do this using "for"?
==============
X=zeros(N+1,1);
X(1)=X0;
for i=1:N
X(i+1)=X(i)+a(i)*b(i)
end
X(1)=[];
plot(t,X)
THANKSSS! :)
now, if I want to insert an image that moves along the line? to be more clear, want a plot like this:
http://www.mathworks.com/matlabcentral/fileexchange/4572-trajectory-and-attitude-plot-version-2
How can I do it? I noticed that the planes are .mat, how do you create? is there a database that contains other vehicles?
thanks again! :)
Matt J
2011-10-02 22:13:11 UTC
Permalink
Post by Bob
http://www.mathworks.com/matlabcentral/fileexchange/4572-trajectory-and-attitude-plot-version-2
============

Might be a good idea to contact the author for advice on how to modify it.
Continue reading on narkive:
Loading...