MATLAB - Plot half the Nyquist Plot - matlab

Is there a way to only plot half the nyquist plot in MATLAB? Nyquist usually has the two lines that go in opposite directions (one going up, and one going down). I only want to plot the one going down.
I know that I can only show the negative axis to "hide" the positive bit of the plot, but I want to show the whole chart, but only have the one line:

Okay, I got the answer. Use nyquistplot instead of nyquist and set the option ShowFullContour to off:
% This is an example contour
G = tf(80, [1 9 30 40]);
h = nyquistplot(G);
setoptions(h, 'ShowFullContour', 'off');

Related

Plotting multiple fitobjects in the same figure in MATLAB 2016b

I have multiple fitobjects that I want to plot in the same figure. All curves are fitted from the same five points on the x-axes (ranging from 0.25 to 2.25). If I plot them individually the curve correctly spans only between does values, however, as soon as I add hold on to plot them in the same figure the first fitobject is plotted correctly, while the second spans from -Inf to +Inf, if I change the order of fitobjects the problem remains. So the first curve is always shown correctly the following ones are not. I am not even setting any axes properties yet. Also the two fitobjects have the same Boundaries for the fit.
Example code:
plot(fitobj{1}, 'r'); hold on %curve from 0.25 to 2.25
plot(fitobj{2}, 'b'); %curve is shown from -Inf to +Inf
Do you know why this is happening? Thank you

Matlab line plot overlaps axis when values are zero

I have plotted a figure with multiple lines on it, and I have noticed that the lines for the plot overlap the x-axis when they are zero. Is there a way that I can essentially get the x-axis to plot on the top, rather than the lines?
Here is a MWE that does the same thing (I haven't put my exact code up as my dataset is quite big).
xdata=1:1:10;
ydata=[1;0.8;0.6;0.4;0.2;0;0;0;0;0];
line(xdata,ydata)
After I plot the lines (multiple per plot in my case), I do various other things with the axes so I get what I need (including adding a secondary set of axes). None of this seems to make any difference as to whether the x-axis is plotted on top of the lines or not.
I did have a search online but couldn't find anything to do with this.
The answer given by Luis is a nice workaround, but the official way to solve this problem is to use the layer property of the axis object, see the manual. To plot the axis on top of the data you do
set(gca,'Layer','top')
To automatically do this for all your plots, you can put the following line in your startup.m:
set(0,'DefaultAxesLayer','top')
This kind of answers you do not make up yourself, I only discovered this trick after asking more or less the same question on comp.soft-sys.matlab many years ago. See also this SO question.
After having plotted all your lines, plot a line on the x axis with the same color as the axis:
hold on
a = axis; %// gives xmin xmax ymin ymax
cx = get(gca,'Xcolor'); %// color of x axis
plot([a(1) a(2)], [a(3) a(3)], 'color', cx)
If the lines also overlap with the y axis and you also want that axis to appear on top, add the following:
cy = get(gca,'Ycolor'); %// color of y axis
plot([a(1) a(1)], [a(3) a(4)], 'color', cy)

Is there any way to restrict the plots in one grapgh?

I'm trying to plot several signals in one graph and i would like to restrict them and sort of minimize it so all my signals will be clear (more or less).
I have no idea how to do it. I'm adding an image so what i need to do will be clearer.
My data changes but in general it's the mean intensity of each column of a certain area in an intensity image.I tried to do it like with the same idea as you but i don't get the right plot as i wanted. A is the relevant matrix,b is the matrix with shifted values:
for i=1:20
b(i,:)=A(i,:)+(100*i);
plot(b(i,:))
hold on
end
I will also add 2 images: one is the plot of all the 20 signals that i get and the other one is the plot of only the first signal. I don't understand why do they look so different.
You can try something like that :
x = [1:100]; %Distance 1 to 100
y = F(x) % Your first function (signal)
y2 = 0.5*G(x) % Your second function (signal)
plot(x,y,x,y2); % plot both function in a single plot.
hleg1 = legend('Intensity t1,'Intensity t27');
So you have your signal at intensity t27 half cut for each value ( 0.5 ), so it shift down.

Dividing a figure and handling Xticks (Matlab)

I have some problems with figures in Matlab. I divided my bar plot into two figures since I have totally 171 bars. I took the first half of the data at first (figure 1) and then the second half (figure 2). But then I got a problem with Xticks. Now both start from zero, but I would want the second half (figure 2) to be from 86 to 171 (or with intervals of 10 so that they are from 80 to 180, for instance). I tried set(gca, ‘XLim’, [86 171] to the second figure, but what happened was that bars in that figure ended up outside the figure, which I hadn’t thought before... Any hints how to solve the problem with the Xticks/dividing the figure?
I also have another question about Xticks! I would want to move them downwards in the figure, since I have added text (or actually other numbers which correspond to different bars) right above every bar. I made the figures to fit the whole screen by “set(gcf, 'Position', get(0,'Screensize'));”, but Xticks should be moved downwards so that Xticks and and other numbers are not on top of each other. I would like to learn how to solve these problems, but it seems like I need help from someone who has more experience!
The x ticks are specified by the X argument to bar().
n = 171;
x = randi(20, n);
subplot(2,1,1)
bar(1:85, x(1:85))
subplot(2,1,2)
bar(86:171, x(86:171))

Command for cutting matlab plot from the middle

I am trying to plot a dataset and want to see a small portion of the plot in the display. The problem is that the dataset is huge and when I am running the algorithm on the whole dataset the significant change in the plot is not clear (visually). Thats why I want to run the algorithm on the whole dataset and want to view a portion of the resulting plot in the display, say 10% of the plot from the middle. Can anyone please help me how to cut the M-figure from the middle - 10% of the original plot? Thanks in advance.
Suppose you're plotting x.
L = length(x);
fraction = 0.1; %#plot 10% of signal
n = round(L*fraction); %#number of samples/points to plot
offset = 0.5 %#start plotting at 50% of the signal (middle)
s = round(L*offset) %#number of samples/points to skip before plotting
t = s:s+n-1; %#discrete 'time' vector, so you know where you are on the plot
plot(t,x(t)); %#plot the selected signal portion
Do xlim, ylim and zlim do what you want?