필터 지우기
필터 지우기

How to assign negative values to a variable

조회 수: 73 (최근 30일)
vetri veeran
vetri veeran 2014년 8월 7일
댓글: Star Strider 2014년 8월 7일
I am getting an error as like this.
Subscript indices must either be real positive integers or logicals.
my code is,
V = -60
am(V)=(0.01*(V+50))/(1-exp(-(V+50)/10))
but i need to pass V=-60 to am(V). how can i pass this.
Can anyone answer for this. Thanks in advance.
  댓글 수: 1
Yu Jiang
Yu Jiang 2014년 8월 7일
It would be more helpful if you could explain what objective you are trying to achieve. It seems like am(V) is a function of V and you would like to get the value of the function at V = -60. If that is the case, you may need to define the function first before passing a value into it.

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

채택된 답변

Star Strider
Star Strider 2014년 8월 7일
편집: Star Strider 2014년 8월 7일
Your ‘am’ function needs to be coded as an anonymous function:
V = -60
am = @(V) (0.01*(V+50))/(1-exp(-(V+50)/10));
amV = am(V)
produces:
amV =
58.1977e-003
  댓글 수: 2
vetri veeran
vetri veeran 2014년 8월 7일
Thank u sir.
Star Strider
Star Strider 2014년 8월 7일
My pleasure!
(Please Accept my Answer if it solved your problem.)

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

추가 답변 (1개)

Hikaru
Hikaru 2014년 8월 7일
편집: Hikaru 2014년 8월 7일
V = -60
am = (0.01*(V+50))/(1-exp(-(V+50)/10))
am(V) in MATLAB means that you want to access the V-th index in the array am, which has to be positive integers or logicals.

Community Treasure Hunt

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

Start Hunting!

Translated by