0
Line 227: f1 = @t v*w*cot((sqrt(v))*(t-t2) + acot((sqrt(u2/w))))/(rout - rb/2 - (t - t2)*(t - t2)*g*(sin(k))/2);

Line 228: f2 = @t x4t2d - quad(f1, t2, t2d);

Lin3 229: t2dapprox = t2 + 0.1;

Line 230: t2d = fsolve(f2, t2dapprox);

Matlab is giving errors: Cant parse at v in 227. Parse error at x4t2d in 228

P.S. All values are (supposed to be) scalars in 227

ρss
  • 5,115
  • 8
  • 43
  • 73
  • `f2 = @t x4t2d - quad(f1, t2, t2d);` isn't even valid Matlab code for defining an anonymous function. Where is this copied out? Show the actual code and provide a runnable example with input values. – horchler May 30 '14 at 21:50

1 Answers1

0

When you declare inline functions like this, you need to tell MatLab which letters are variable - by default it assumes x is a variable, but here you use v, w, t... and a bunch of others - declare this in your function

Mauvai
  • 461
  • 2
  • 5
  • 17
  • I don't know what the OP's code is, but it looks more like anonymous functions than inline functions. – horchler May 30 '14 at 21:51
  • @ Mauvai and @ horchler It turned out that x4t2d, which was calculated based on some input information was calculated wrongly due to noise in input. This made the equation wrong. Also I made the correction, f1 = @t v*w*cot((sqrt(v))*(t-t2) + acot((sqrt(u2/w))))./(rout - rb/2 - (t - t2).*(t - t2)*g*(sin(k))/2); - used ./ and .* . Now the equation works, I appreciate help. – user3651001 Jun 02 '14 at 10:42
  • One more thing, all the variable names in the f1 expression (except 't') denote some constant whose value has been calculated in the code preceding: f1 = @t v*w*cot((sqrt(v)...... – user3651001 Jun 03 '14 at 00:16
  • If they're being calculated in the code then whether or not they're constants from then on, the code sees them as variables, and must be treated as such. – Mauvai Jun 05 '14 at 09:31