help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with matrix "undefined near line 1 column 1"


From: Doug Stewart
Subject: Re: problem with matrix "undefined near line 1 column 1"
Date: Thu, 27 Nov 2014 20:20:50 -0500



On Thu, Nov 27, 2014 at 4:42 PM, tomas92 <address@hidden> wrote:
I'm having trouble progressively building a matrix with vertcat. This should
be fairly simple but I can't seem to find the error in the code. What I do
is, I define A as a line vector (3 columns), and progressively add lines to
it inside a "while" with vertcat like this:

while X(3)<...
X=X+....
A=vertcat(A, X);
endwhile

I know the functione vertcat works alright because I've been testing it
manually, but for some reason a code like this doesn't work. It runs
apparently fine, but when I ask for the matrix it sais it is "undefined near
line 1 column 1". Does anyone notice the mistake or is Octave just messing
up?

Here is the actual code, with f2 and DT being functions with a size 3 line
vectors as input and output.


p=200:50:300; tinf=zeros(1, length(p));
for k=1:length(p); global Tv; Tv=p(k); T=fsolve('f2',[24 32 42]); T3=T(3);
tinf(k)=rk4wh(0.1, [20 20 20], T3,k)
end

with the following rk4wh:

rk4wh.m

function [t]=rk4wh(h,Xa,T3,k)
global Tt;
t=0; X=Xa;
A=X;
while X(3)/T3<0.99
t = t + h;
K1 = h*DT(X);
K2 = h*DT(X+K1/2);
K3 = h*DT(X+K2/2);
K4 = h*DT(X+K3);
X = X+(K1+2*K2+2*K3+K4)/6;
A=vertcat(A, X);
endwhile
Tt{k}=T;


Without trying to understand you code I see that  T has not been defined.


 
end


My intention is to progressively build "A" inside the "while" as I had said
previously and then store the full matrix in a cell array Tt. The main part
of the program runs fine and I can get what I believe is the right solution
for tinf. I have already tried defining A as a global matrix and asking for
it separately from Tt, but the error is the same.



--
View this message in context: http://octave.1599824.n4.nabble.com/problem-with-matrix-undefined-near-line-1-column-1-tp4667551.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave



--
DASCertificate for 206392


reply via email to

[Prev in Thread] Current Thread [Next in Thread]