Array indices must be positive integers or logical values

Array indices must be positive integers or logical values.
Error in untitled (line 49)
pb = logninv ( ((C8 /Tb)+C9+(C10*Tb)+(C11*Tb^2)+(C12*Tb^3)+C13*log(Tb)) ); %"Wexler's Equation for Saturatoin pressure"
Can Anyone help me in this issue!

4 Comments

What data types are your variables in this equation? Please share your workspace variables.
Check to see if you have a variable named loginv or a variable named log
There is no variable named logninv or log
Can you upload the file untitled.m (using the button with the paperclip icon)?

Sign in to comment.

Answers (1)

Do you have variables called log or logninv?
If so, MATLAB will treat, e.g., log(Tb) as taking element(s) at index Tb in the array log, rather than calling the log function with argument Tb.
Since there are no other possible indexing operations on that line, it seems likely that log and/or logninv has been used as a variable name. To find out, you can do this right before that line:
whos log*
If there are any variables called log or logninv that show up when you do that, you should rename them in your code to something that doesn't have the same name as a function you want to call.

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

on 12 Apr 2022

Commented:

on 12 Apr 2022

Community Treasure Hunt

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

Start Hunting!