matlab-figure

How to change the font size of a plot's title and axis labels and save it?

人盡茶涼 提交于 2019-12-02 09:15:42
问题 Every time I save a plot picture as jpg or png, font size of title and axis label is changed back to default automatically. My code is like this: figure plot(x, f(x)) title('the smallest n = 1', 'FontSize', 24); xlabel('x', 'FontSize', 24); ylabel('x''', 'FontSize', 24); After saving the picture, those font sizes become small again. Anyone knows why? 回答1: Because it just applies for the current figure. If you want to set the same font size for the whole session, use: set(0,

Matlab: replace one plot maintaining others

廉价感情. 提交于 2019-12-02 08:21:52
I have a figure in which I plot some disperse points and then a trajectory. I want to switch between different trajectories by plotting them in the same figure as the points, but without creating new figures, i.e., "erasing" the first trajectory and then plotting the new one. Is there a way of doing this? Perhaps this little demo will be helpful: xy = rand(20,2); figure % Plot first iteration and output handles to each h = plot(xy(:,1),xy(:,2),'b.',xy(1:2,1),xy(1:2,2),'r-'); axis([0 1 0 1]) % Update second plot by setting the XData and YData properties of the handle for i = 2:size(xy,1)-1 set

Using getframe in Matlab on Windows

自作多情 提交于 2019-12-02 08:20:17
问题 I used the code which I asked about here but added in the final loop the ani(ii)=getframe; and after the loop movie2avi(ani, 'orbeeit.avi', 'compression', 'None'); . instead of proper avi I get a frozen smashed avi (length 10 sec) which its only frame is this one . What am I doing wrong? 回答1: This problem is probably caused by Windows Vista (and newer) in conjunction with certain graphics drivers as described in this bug report. You can change the renderer after you created the figure: set

Plotting piecewise function

只愿长相守 提交于 2019-12-02 08:03:26
问题 I have a solution to a differential solution but the issue is that I have different solutions in different intervals. For examle: x_1(t) when t belongs to [0,t_1] x_2(t) when t belongs to [t_1,t_2] x_3(t) when t belongs to [t_2,t_3] Now I need to plot these graphs so that they look like they have a single function i.e just immediately after the first graph x_1(t) until t_1 , I need the other graph x_2(t) and so on. Is it possible in Matlab? 回答1: You can use plot with multiple inputs to plot

How do I fill in the area between two lines and a curve that's not straight in MATLAB (the region is not a polygon)

十年热恋 提交于 2019-12-02 07:00:28
问题 Using matlab's FILL function creates a filled region confined by a polygon with straight edges: Unfortunately this leaves a small white region in the figure above, because the boundary of the region I want filled in is not a straight-edged polygon, but rather has a curved boundary on the left side. I have a curve (nearly parabolic but not exactly), and I want to fill in the region between two horizontal lines AND the curve itself. I also looked into the MATLAB function IMFILL, but with no

Change the axis scale of imshow

…衆ロ難τιáo~ 提交于 2019-12-02 06:55:55
问题 I'm visualizing a matrix in MATLAB with imshow . However, I'd like the y and x axis to switch places, making x correspond to the row-index of the matrix, and y correspond to the col-index. I also want to change the increment value of the axises to 0.01, so that row 10 has x value 0.1, row 100 has 1 and so on. 回答1: To swap the axes you will want to change the view of the axes. By default the 2D view has the y axis vertical and x axis horizontal. You can change this by rotating the view 90

How to halt matlab plot3 scale

拥有回忆 提交于 2019-12-02 06:44:11
问题 I want to plot pendulum (which changes position) using plot3 function. Unfortunately, when my dot changes position in loop and is being plotted again, the scale of 3d plot is changing too, so the x axis depending on position changes (depending on position of the dot it can be from -1 to -1.5 or from -1 to -3) and y changes also. Only z states the same. The result is that the dot jumps on graph and does not create impression of pendulum. This is how I plot: plot3(0,0,0); daspect([1,1,1]); axis

Plotting data with time series in matlab

北战南征 提交于 2019-12-02 06:12:34
I have some data from 2007/5/1 to 2007/5/30 from 00:00 to 23:59:58. I want to plot these data according to data and time together. How can I define both date and time together? cause it has a regular date and time. For example 2007/5/1 00:00:00 -0.2 2007/5/1 00:00:02 -0.1 2007/5/1 00:00:04 -0.12 . . . 2007/5/31 23:59:58 -0.4 I've been used DateTime code but I have regular time interval and I don't know how to solve it. Here is an example for using a datetime variable. You'll need to import your data to a corresponding vector that aligns with the time vector ( t below) so that data(i) is the

How to flip the x-axis?

纵饮孤独 提交于 2019-12-02 05:45:51
I am plotting amplitude reconstruction of FMCW radar. I want to flip the inside graph only. However the x axes shoud be the same. How shoud i do it. Below is my code for plotting. for i = 1:2500 %%%% dividing each row by first row. resd(i,:) = res3(i,:)./res3(1,:); end f = fs/2*linspace(0,1,nfft/2+1); %%%% defining frequency axes K = BW/Tm; t = f/K; deltaf = 1/max(t); fmax = 1 / t(2)-t(1); f1 = 0:deltaf:fmax; % f1 = fmax:deltaf:0; f2 = f1 + fc; %%%%%% Amplitude reconstruction figure(1),plot(f2,abs(resd)); [![enter image description here][1]][1] As be found in the axes documentation , it's

How to avoid displaying zero-values in confusion matrix

孤街浪徒 提交于 2019-12-02 05:30:29
I plotted a confusion matrix in Matlab using the code from this link . However whenever there is a zero on the cell it is still shown. How can I eliminate the printing of 0.00 's on the cells? Sample of my confusion matrix After you removed all spaces, find '0.00' and substitute it with spaces again idx = find(strcmp(textStrings(:), '0.00')); textStrings(idx) = {' '}; The complete code will then be: mat = rand(5); %# A 5-by-5 matrix of random values from 0 to 1 mat(3,3) = 0; %# To illustrate mat(5,2) = 0; %# To illustrate imagesc(mat); %# Create a colored plot of the matrix values colormap