Area under surface between two curves [duplicate] - matlab

This question already has an answer here:
Area between line and curve (no function)
(1 answer)
Closed 6 years ago.
I want to determine the area between the red line and the blue line but only to the y-value of 4.559. How can I achieve that?

In general:
First you have to subtract the two functions from each other. After
that, you have a function that represents the delta in y for each
point on the x-axis.
After that you have to calculate the integral, for matlab you should look here Matlab - Numerical Integral
The last step is inserting the left, and the right bound of your desired area to calculate. The result is the area under the surface
Be careful when subtracting the functions, the result of the area might be negative (negate it in this case) if the "bigger" function is the subtrahend

Related

Matlab. Absolute markersize [duplicate]

This question already has answers here:
How to plot a circle in Matlab?
(2 answers)
How to plot a filled circle?
(1 answer)
Closed 5 years ago.
I know I can plot a dot and select its size with the word 'markersize' like this
plot(0,0,'.','markersize',50) %Dot centered in (0,0)
The size of the dot produced does not change if we amplify the plot. It always seems to have the same size to our eye. I would like to produce dots (or circles) with a real radius, so that when the image is amplified it appears bigger. What are my options?
Use rectangle command with curvature [1 1] it will draw circles with relative radius.

What is the default colour of the x, y and z axis in Matlab? [duplicate]

This question already has answers here:
What is the default MATLAB Color Order?
(2 answers)
Closed 7 years ago.
This may seem like an overly simple question. What is the default colour of the x, y and z axis in Matlab? I have searched the internet and can't seem to find an answer. Bellow is a sample graph. As I know the data, I think the blue line represents z axis, red represents y axis and yellow represents the x axis. However, I am not sure and would like someone to confirm this,
Thanks.
Matlab will colour plots consecutively from the same palette in the order in which you call the ´plot´ commands, so in all your examples the blue line is the first one you plotted and so on. The colororder is static but can be changed. See this page for the order and how to change it.
As far as 'x, y and z' goes are you referring to the meanings you have ascribed to the data? Because matlab doesn't infer anything like that - if your variables are called x or y or whatever it will ignore that and plot them in the order you called the plot commands.

MATLAB: How to change color of graph? [duplicate]

This question already has answers here:
Matlab Bar Graph - fill bars with different colours depending on sign and magnitude
(2 answers)
Closed 9 years ago.
This is the question I need to answer:
So far my function only reads:
function eval = plotupc(x)
bar(x, 'histc')
end
When I try to change the color of the graph, it stops my graph from being a histogram. Also, how can I make it so that my graph starts at 0 rather than 1?
The bar documentation states that
Note: You cannot specify names and values when using hist or histc options.
Instead, you can set the x-axis locations and bar width manually:
bar(0.5:numel(x)-0.5, x, 1, 'k');
axis tight;
The first argument gives the x locations of the bars; another example here. Here the bars are shifted one half to the right.
The second argument is of course your input.
The third argument specifies the width of the bars, a width of 1 ensures that they touch.
The last argument, 'k' is for key, i.e. black.
Finally, axis tight makes sure there is no leftover whitespace at the edges of the plot.
t=bar(0:1:length(x)-1,x,'histc');
set(t,'facecolor','k');
xlim([0 length(x)-1]);

Moving a point along a curve in matlab [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Points moving along a curve within MATLAB
I have two arrays ,the first represents the x-axis values and the second represents the y-axis values of a certain curve. I want to draw a point (or some object) that moves along that curve in MATLAB.
You can just trace the curve, i.e., you can place the cyrsor on the curve and press left or right to move your cursor across it.

Two left Y axis [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Plotting 4 curves in a single plot, with 3 y-axes
Dear stackoverflowers,
I need to plot 3 curves with same X axis (time) but three different dimensions (Volt, temp, current). The best outlook, to me, would be to have two Y axis on the left side, separated by a few pixel so we can read legend and ticks for each.
The answer to my questions are not plotyy neither multiple X or Y axis . In the first case, it helps me plot two different dimensions, not three.
the latter helps me associate right or left Y axis to a particular curve. I used the YAxisLocation option for my third curve but if I put it right or left, of course it interfers with the other YAxis that was there before. There is no option like left - 20 pixels ?
Thank you for your help.
You could just use plot (which will take care of the scale) and then include a legend to say what your units are (e.g. volts, degrees, etc)