You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Area under curve with negative X and Y values
4 views (last 30 days)
Show older comments
I want to use the area() function, but I have negative x and y values on the axes
10 Comments
Naomi Amuzie
on 18 Jun 2019
I have two vectors for the x and y axes. both contain negative valeus (vectors). Using plot works, using area doesn't.
Naomi Amuzie
on 18 Jun 2019
Edited: Naomi Amuzie
on 18 Jun 2019
when attempting to do area(), I get this error:
"Index in position 1 is invalid. Array indices must be positive integers or logical values."
Star Strider
on 18 Jun 2019
Show your vectors and your area call.
This does what we expect it to do:
x = linspace(-5, 0, 5);
y = -x.^2/5;
figure
area(x, y)
Walter Roberson
on 18 Jun 2019
You have accidentally created a variable named area that is interfering with your call to the area() plot.
Naomi Amuzie
on 18 Jun 2019
the x-axis: [0 -0.650000000000000 -2.60000000000000 -5.60000000000000]
y-axis: [0 -0.422618261740699 -0.845236523481399 -1.26785478522210]
Walter Roberson
on 18 Jun 2019
Run the code. When it stops with an error, show the result for
which -all area
Naomi Amuzie
on 18 Jun 2019
I get what you said, strangely. i don't have a variable named area though...
"area is a variable.
/Applications/MATLAB_R2019a.app/toolbox/matlab/polyfun/@alphaShape/area.m % Shadowed alphaShape method
/Applications/MATLAB_R2019a.app/toolbox/matlab/polyfun/@polyshape/area.m % Shadowed polyshape method
/Applications/MATLAB_R2019a.app/toolbox/coder/half/@half/area.p % Shadowed half method
/Applications/MATLAB_R2019a.app/toolbox/matlab/specgraph/area.m % Shadowed"
Naomi Amuzie
on 18 Jun 2019
Oh! There wasn't a variable in my code, but there was a variable in my workspace I created a long time ago, but never deleted.
Thank you! Sorry about the hassle!
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)