matlab-figure

Pick a specific level in the contour plot on matlab

微笑、不失礼 提交于 2019-12-31 05:07:14
问题 I have this plot that I generated as a test of figuring out how contour plots work on matlab in general. I'm trying to figure out if there is a way I can plot just one of the lines but not necessarily the first line. They way Matlab explains it is if you do: contour(X,Y,Z,1); it will plot one of the lines but it's always the first one, but for my particular case I want the 3rd or 4th one. Is there a way to do that in Matlab? 回答1: contour(Z,N) and contour(X,Y,Z,N) draw N contour lines,

How to have a common label for all x and y axes in case of subplots?

假装没事ソ 提交于 2019-12-31 04:11:22
问题 I have used the following loop to get subplots: for j=1:19; Aj=B(j,:); subplot(5,4,j); plot(Aj,h) end For all these subplots, I need to have only one x-label and one y-label. How to do this? Also how to insert legend to all the subplots? 回答1: You can use suplabel from the FileExchange to have combined x and y label for all subplots. Example: subplot(1,2,1); plot(randperm(40)); hold on; plot(randperm(40)); %Plotting some random data legend('show') %To show the legend subplot(1,2,2); plot

Shading of area between two lines not working correctly in MATLAB

北战南征 提交于 2019-12-31 01:56:10
问题 I am trying to plot the shaded uncertainty (upper and lower bounds) along a line. I tried using the fill function but it is including an area larger than I want. I have an upper error (black), lower error (green), and actual data line (red), like so: How do I get the area between the green and black lines? I tried the following: fill([date fliplr(date)], [data_Upper fliplr(data_Lower)], 'r'); But the fill function covers both line areas all the way to the bottom of the plot: How do I fix this

Text 'Extent' property doesn't contain the correct size

谁说我不能喝 提交于 2019-12-30 18:47:13
问题 I want to place some text in a GUI, and I want to know the exact size the uicontrol of type 'text' needs to be! I've found several threads explaining that this can be done using the 'Extent' property of a 'text' object containing the same text, see example: function form = tempfunc(txt,font,fontsize) if nargin <3 fontsize = 10; end if nargin < 2 font = 'courier'; end f = figure('Visible','off','Units','pixels'); u = uicontrol(f,'Style','text','Units','pixels','String',txt,'FontName',font,

How to rotate image and axes together on Matlab?

那年仲夏 提交于 2019-12-30 15:40:19
问题 Code 1 where flipping vertically and/or horizontally does not affect axes() ; Code 2 where proposed solution does not yield the expected output close all; clear all; clc; x = [5 8]; y = [3 6]; C = [0 2 4 6; 8 10 12 14; 16 18 20 22]; C2 = C(:,end:-1:1,:); %# horizontal flip C3 = C(end:-1:1,:,:); %# vertical flip C4 = C(end:-1:1,end:-1:1,:); %# horizontal+vertical flip % https://stackoverflow.com/a/4010203/54964 subplot(2,2,1), imagesc(x,y,C) subplot(2,2,2), imagesc(x,y,C2) subplot(2,2,3),

How to rotate image and axes together on Matlab?

流过昼夜 提交于 2019-12-30 15:39:24
问题 Code 1 where flipping vertically and/or horizontally does not affect axes() ; Code 2 where proposed solution does not yield the expected output close all; clear all; clc; x = [5 8]; y = [3 6]; C = [0 2 4 6; 8 10 12 14; 16 18 20 22]; C2 = C(:,end:-1:1,:); %# horizontal flip C3 = C(end:-1:1,:,:); %# vertical flip C4 = C(end:-1:1,end:-1:1,:); %# horizontal+vertical flip % https://stackoverflow.com/a/4010203/54964 subplot(2,2,1), imagesc(x,y,C) subplot(2,2,2), imagesc(x,y,C2) subplot(2,2,3),

Visualizing large 3D dataset with scatter plot

亡梦爱人 提交于 2019-12-30 10:55:07
问题 I'm running a simulation in MATLAB in which I have a large 3D dataset that changes each time step. I'm trying to visualize the data using a 3D scatter plot with points that take on different locations, sizes, colors, and transparency levels as the simulation proceeds. The size and color information are redundant. Rendering and rotating the figure in MATLAB is slow and choppy. My computer has a 4 GHz i7-4790 CPU and a NVIDIA GeForce GTX 750 Ti graphics card. I am using Matlab R2016a on Windows

How to set the origin to the center of the axes in Matlab

独自空忆成欢 提交于 2019-12-30 10:20:51
问题 When I plot a function f(x) in Matlab, for example, the sine function, the graph I get is this: I want to plot it in a rather different way, such as this, generated with Mathematica: Note the axes position (together with the ticks), and the x and y labels position. Any help would be very appreciated. 回答1: Because not all readers have the latest version of MATLAB, I decided to make this answer a little bit more general, so now it's a function, that get as input the handle to the figure to

Removing the line between two specific data points in Matlab

倖福魔咒の 提交于 2019-12-30 10:07:25
问题 I am going to draw a graph in Matlab. The graph is quite simple and I am using the plot function. Suppose the data that I want to plot is (0:1:10) . I also put markers on my graph. Then, we have a line that has markers on coordinates (0,0),(1,1),(2,2),... etc. Now, I want to remove the line between (2,2) and (3,3) without deleting the whole line. That is to say, my purpose is to get rid of a particular segment of the line without loosing the entire line or any marker points. How can I do that

Labeling different figures, font,size MATLAB

此生再无相见时 提交于 2019-12-30 10:06:37
问题 I am trying to basically copy this graph for practice for my final coming up but I don't understand how to change the font,size or labeling the axis. Simply put, I need to replicate this graph exactly from my code. I need the font to be times new roman and size 18 with a marker size of 8. How would I format my code into this? This is my code: clear clc x = linspace(0,2); y1 = sin(2*pi*x); y2 = exp(-0.5*2*pi*x).*sin(2*pi*x); figure subplot(2,1,1); hPlot1 = plot(x,y1,'rs'); ylabel('f(t)') set