MATLAB: How to find a Y value of a given X

MATLAB

Hello, this is a very simple question. I am writing an equation for v given t:
t = 0:0.00001:0.01;
v= 50*exp(-1600*t) - 50*exp(-400*t);
How would I find the value of v at a certain t? I want to find what v is when t=0.000625.

Best Answer

This is easiest if you create ‘v’ as an anonymous function:
t = 0:0.00001:0.01;
v = @(t) 50*exp(-1600*t) - 50*exp(-400*t);
ti = 0.000625;
Out = v(ti)
figure
plot(t, v(t))
hold on
plot(ti, v(ti), 'r+')
hold off
grid
See Anonymous Functions for details.