Resources

create a vector with a variable as an element

0

Hi

I want to create a vector called “gss” with m but got the following:

m=-ln(0.5/0.24212945-1);
gss={m,1};

m
-0.062985214

gss[1,1]
+DEN

Why is that gss[1,1] is not equal to m? Plus why can’t I just do gss={m}?

Thanks for your help!

Laura

Tags: asked July 31, 2013

1 Answer

0

The reason that gss[1,1] is not equal to the value of m (-0.06298) is because GAUSS allows you to add character elements to matrices and vectors. So what you actually added to gss was the character element m. You can see this by printing it as a character element by prepending with the $ like this:

m=-ln(0.5/0.24212945-1);
gss={m,1};

print $gss[1,1];

results in:

   m

Depending upon what else is going on in the program you could do something like this:

//the pipe operator '|' performs vertical concatenation
gss = -ln(0.5/0.24212945-1)|1;

//or this
gss = ones(2,1);
gss[1,1] = -ln(0.5/0.24212945-1);
aptech
342