Index exceeds number of array elements

expression1a = 3*cos(pi) - 2*log(3) + exp(4);
fprintf('The answer to 1A is: %.6f\n', expression1a);
I'm getting an "index exceesds number of array elements" error when I try to run this, even though it was working 5 minutes ago. What can I do to fix this?

답변 (1개)

Walter Roberson
Walter Roberson 2024년 3월 9일

0 개 추천

You accidentally created a variable named log or named exp

댓글 수: 3

Grace
Grace 2024년 3월 9일
I can't find any instances were there is a created variable by that name.
expression1 = 3*cos(pi) - 2*log(3) + exp(4);
fprintf('The answer to 1A is: %.6f\n', expression1);
The answer to 1A is: 49.400925
%1B
lvalue = log(150)/log(7);
expression1b = (atan(2) + lvalue - nthroot(88, 4))/(abs((sin(4)) - 1.4^1.4));
fprintf('The answer to 1B is: %.6f\n', expression1b);
The answer to 1B is: 0.262579
Does it have something to do with the next few lines?
Torsten
Torsten 2024년 3월 9일
I'd leave MATLAB and try a new session.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

태그

질문:

2024년 3월 9일

댓글:

2024년 3월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by