cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Unexpected 'undefined variable' error?

JohnWoodgate
6-Contributor

Unexpected 'undefined variable' error?

I expect this is something stupid I've done, but I can't see what.The attached file accepts the variable 'z until the last line. Why?

1 ACCEPTED SOLUTION

Accepted Solutions

Prior to your problem with z; x and y are predefine vectors, but z was always input as a scalar in the functions.

Up to the point of your problem, the variable z was never assigned a value, out side of an argument list.

In the last equation cf does not have an argument list (x,y,z), which I think you want. At least you need cf(z)=

Since the vectors x and y were defined prior to the function definition, they do not actually have to be in the argument list, unless you want to use the functions again with different x and y vectors.

View solution in original post

2 REPLIES 2

Prior to your problem with z; x and y are predefine vectors, but z was always input as a scalar in the functions.

Up to the point of your problem, the variable z was never assigned a value, out side of an argument list.

In the last equation cf does not have an argument list (x,y,z), which I think you want. At least you need cf(z)=

Since the vectors x and y were defined prior to the function definition, they do not actually have to be in the argument list, unless you want to use the functions again with different x and y vectors.

JohnWoodgate
6-Contributor
(To:wayne)

Thanks: something stupid, as I thought. cf should be cf(x,y,z).

Top Tags