Creating an equation with multiple inputs.

조회 수: 7 (최근 30일)
Alexander
Alexander 2013년 11월 12일
답변: Walter Roberson 2013년 11월 12일
I'm trying to make an equation where I put in three variables and get an answer. This is what I have so far. Every time I try to run it, it says "undefined function or variable 't.'"
line(t,A_0,a);
N(t) = exp^(A_0/a)*(1-exp^-at);
line(4,3,5);

답변 (2개)

Image Analyst
Image Analyst 2013년 11월 12일
As you have used it, t needs to be an index - an integer like 1, 2, 3, 4, etc. Or it can be a logical vector if you've previously defined N.
The way you've used line(), t, A_0, and a must be arrays, not scalars, so in that case you must use dots in your equations to process all elements of the array:
N(t) = exp^(A_0 ./ a) .* (1-exp(-a .* t));
and I don't understand your second call to line - it doesn't make sense.
  댓글 수: 2
Alexander
Alexander 2013년 11월 12일
the second call line was the numbers I was trying to plug in for each variable. I did what you said, but it's still giving me the same error.
Image Analyst
Image Analyst 2013년 11월 12일
Look up line() in the help to see how it should be used.
It's hard to debug a program when most of it is missing, particularly the code before the three lines that you snipped out.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2013년 11월 12일
My guess is that you want
function N = line(t,A_0,a)
N = exp^(A_0./a).*(1-exp.^(-a.*t));
end

카테고리

Help CenterFile Exchange에서 Pie Charts에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by