MATLAB Answers


Strange problem with an equation

Asked by Christian
on 7 May 2013

So I'm working on this school project where we have to calculate T from an equation using fsolve. But Matlab won't use my equation, because T isn't estimated yet.

So when i run the script:

JacobFormula = ((Q)/(4*pi*T))*(log((2.25*T*t)/((r^2)*S)))-s;

The output is:

Undefined function or variable 'T'.

Which results that i can't go futher to find T. (All the other values are known)




No products are associated with this question.

1 Answer

Answer by the cyclist
on 7 May 2013

First, the way you have defined JacobFormula, it is a variable and not a function. Here is a simple example of defining a function:

>> F = @(T) 3*T;

Then you can see that

 >> F(8)
ans =

You will be able to use that function F as an argument to fsolve.


Oh thank you, that got me a little futher :-) But now it comes up with this:

Error using ^ Inputs must be a scalar and a square matrix. To compute elementwise POWER, use POWER (.^) instead.

Error in @(T)((Q)/(4*pi*T))*(log((2.25*T*t)/((r^2)*S)))-s

Can you post your full code, or at the very least a self-contained portion that can be run from scratch?

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!