Hello i have problem with trapz method. I wrote a very easy code but i have an error with it. I would be very gratefull if someone find a reason of this madness.
clear all
clc
X =[1:10];
Y = X.^2;
a=trapz(X,Y);
disp(a)

답변 (1개)

Star Strider
Star Strider 2015년 2월 1일

0 개 추천

You code runs for me without error.
In the Command Window, type:
which trapz -all
My guess is that the first line will be:
trapz is a variable.
In that situation, you will need to rename whatever your current ‘trapz’ variable is so the trapz function will work correctly.

댓글 수: 4

Kamil Tkacz’s ‘Answer’ moved here ...
>> which trapz -all
C:\Users\Gab\Desktop\trapz.m
C:\Program Files\MATLAB\R2013a\toolbox\matlab\datafun\trapz.m % Shadowed
Star Strider
Star Strider 2015년 2월 1일
That is essentially the same message. ‘Shadowed’ means that you have another function or variable somewhere called ‘trapz’.
You need to find that other function or variable named ‘trapz’ and rename it to something other than a MATLAB built-in function name. Then the trapz function will work as it should.
Kamil Tkacz
Kamil Tkacz 2015년 2월 1일
Its works man!!! Thank u so much :)
Star Strider
Star Strider 2015년 2월 1일
My pleasure!
The most sincere expression of appreciation here on MATALB Answers is to Accept the Answer that most closely solves you problem.

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

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

질문:

2015년 2월 1일

댓글:

2015년 2월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by