How to plot upper limits or lower limits in MATLAB - matlab

I want to plot upper limits of points with arrows in MATLAB, like upper limits in python matplotlib.
I have tried by using errorbar and quiver, but the quiver doesn't show the arrowhead at last.

Related

Setting a negative value for the center of a polar plot MATLAB

Using MATLAB I would like to plot antenna radiation pattern whose maximum value is set to 0. The remaining values are negative and 0 should be at the outermost circle in a polar plot. If I use regular polar() function negative values are put on the opposite side of where it should be. Thus, the polar plot looks like it is flipped. I don't want that. I want maximum value, which is 0 to be at the outermost circle, whereas the remaining negative values are towards the center, not at the opposite side. You can see an example plot down below. How can I accomplish drawing such a polar plot? I would appreciate your help.
rlim seems to do the trick:
theta=linspace(0,2*pi,200);
%% The pattern has negative values
pattern = 10*log10(abs(1+exp(1j*17*sin(theta))));
%% Makes the max of the pattern 0
pattern=pattern-max(pattern);
%% Plots the figure
figure
pax = polaraxes;
polarplot(theta,pattern)
%% This is what you want. Add a little bit of extra space after the minimum and maximum value
rlim([min(pattern)-3 max(pattern)+1])

Adjusting window-size to surf()-plot, Matlab

We're encountering a problem while plotting the frequency of our signal with the surf()-function. As you can see in the picture below, it doesn't fully fill up the plot window. How do we adjust it so that the left plot fills out the graph as well as the right one (which is using spectrogram())?
Picture of our plots:
You can use xlim and ylim to set the limits of the x and y axes. In your case, you could consider something like:
ylim([min(Frequency) max(Frequency)]

Plot lots of points with alpha value in Matlab

When you want to plot scatter points with fixed alpha value in Matlab, you may the patch function, like advised in this SO question. But when you want to plot a high number of individual points, you should use the plot function, as advised in this SO question.
Is it still possible to plot a high number of scatter points with fixed alpha value in Matlab ?

boxplot the data of the y-axis of a scatter plot using matlab

What I basically want to do is to have boxplots for one data set on a scatter plot using Matlab.
We can do the scatter plot with scatter(X, Y) and instead of the points corresponding to Y, I would like to have boxplots.
Something like scatter(X, (boxplot(Y)) - which of course does not work.
Have been searching high and low but could not find a relevant answer, or even something similar.
The scatter-points from the left-hand side have to be replaced with box plots as on the right:

How to set an arbitrary direction on a contour plot to perform operation in Matlab

I am looking for help for my particular problem.
I have a contour plot created from XYZ data. This plot contains 2 broad peaks with one more intense than the other.
When the most intense peak is aligned with the Y axis, I can perform a fitting of every YZ curve at each X values. I usually do a gaussian fit to plot the peak center on the same graph.
In some cases I need to perform the same fitting but no along the Y axis direction (in this case I just plot YZ scan at every different X values) but along another arbitrary direction.
For the moment the only way I found is the following:
-plot the contour plot and find for the position of the most intense peak
-if the position is not aligned with the Y axis, then rotate all the datas and plot again the contour
-perform the YZ gaussian fit for every X value
- Rotate the resulting XY position to go back to the original plot
-plot the XY position as a line on the original contour plot
this is quite long and requires a lot of memory. i would like ot know if there is a more elegant/faster way.
Thanks for your help
David
I take it you want to extract data from the (x,y,z) data along some arbitrary line in order to make a fit. A contour plot will show only part of the data, the full z(x,y) data can be shown with imagesc etc. Say you want the data along line defined by two points (x1,y1) -> (x2,y2). According to the eq of the line, the line y=a*x+b the slope a is (y2-y1)/(x2-x1) and b=y1-a*x1. For example, I'll select (x,y) coordinates in the following contour:
Create data and end points:
m=peaks(100);
x1=11 ; x2=97;
y1=66; y2=40;
Thus the line parameters are:
a=(y2-y1)/(x2-x1);
b=y1-a*x1;
and the line is:
x=x1:x2;
y=round(a*x+b);
select the proper (x,y) elements using linear indexing:
ind=sub2ind(size(m),y,x)
plot:
subplot(2,1,1)
contour(m,10); hold on
line([x1 x2],[y1 y2],'Color',[1 0 0]);
subplot(2,1,2)
plot(m(ind))
You can now use vec=m(ind) to fit your function.