matlab-figure

Error: Input grid is not a valid Meshgrid

橙三吉。 提交于 2019-12-23 02:27:13
问题 I have a question. So I have a 3D matrix of XxYxZ = 10x5x20. I want to plot this matrix with the help of isosurface. So first I need to create a mesh grid, but here comes the first problem when I say: [X,Y,Z] = meshgrid(1:10,1:5,1:20) I get a grid of 5x10x20, but I want 10x5x20. Why is this? My idea was to just change the X and Y [Y,X,Z] = meshgrid(1:10,1:5,1:20) When I try to plot the matrix with the help of this grid: isosurface(X,Y,Z,M) I get the error "Input grid is not a valid MESHGRID"

MATLAB: Print contents of uipanel to PNG image

笑着哭i 提交于 2019-12-23 01:13:46
问题 I don't know how to accomplish the following in MATLAB. I have a figure which looks like this: In the figure, I have a panel with many subplots and a scrollbar that allows me to view a portion of the panel. I want to save the whole contents of the panel to a PNG image file (not just the visible portion), i.e. I want to have a file which is a tall rectangle, and doesn't require scrolling. The code for generating the figure is as follows: function draw(obj) figure; panel1 = uipanel('Parent',1);

Matlab imline snapping

≯℡__Kan透↙ 提交于 2019-12-22 22:39:32
问题 Is there a way to make the ends of a line created by imline snap to the nearest data point on a curve? I'm trying to measure the slope between two points on a curve. The imline is great, but the ends of the line created by it do not snap to data points on a curve. I'm wondering if I can drag the line around while both ends of the line remained on the curve. 回答1: It can be done using the 'PositionConstraintFcn' property of imline. Its value specifies a function handle that is called whenever

MATLAB simple slider on a figure

和自甴很熟 提交于 2019-12-22 10:58:30
问题 I have a matrix to be plotted one column at a time. Is it possible to add a slider to a MATLAB figure (without heavy GUI programming) so that by moving the slider, different columns are shown in the current axis? 回答1: Here is a code for a slider to plot corresponding column: m = ones(5,1)*(1:5); slmin = 1; slmax = size(m,2); plot(m(:,1)) hsl = uicontrol('Style','slider','Min',slmin,'Max',slmax,... 'SliderStep',[1 1]./(slmax-slmin),'Value',1,... 'Position',[20 20 200 20]); set(hsl,'Callback',@

Matlab updating subplots and hold on

柔情痞子 提交于 2019-12-22 10:53:15
问题 I am having trouble with updating subplots. I've boiled my problem down to the following example: win = figure(1); win.sub1 = subplot(2, 2, 1); win.sub2 = subplot(2, 2, 2); win.sub3 = subplot(2, 2, 3); win.sub4 = subplot(2, 2, 4); x = 1:1:10; plot(win.sub2, x, x); %graphs the line y = x in the second subplot, good. hold on; plot(win.sub2, x, -x) %ought to plot line y = -x over line y = x, but does not. When executing the second plot, the first plot disappears despite the hold on. The only

How can I fill an area below a 3D graph in MATLAB?

泪湿孤枕 提交于 2019-12-22 06:29:43
问题 I created the following 3d plot in MATLAB using the function plot3 : Now, I want to get a hatched area below the "2d sub-graphs" (i.e. below the blue and red curves). Unfortunately, I don't have any idea how to realize that. I would appreciate it very much if somebody had an idea. 回答1: You can do this using the function fill3 and referencing this answer for the 2D case to see how you have to add points on the ends of your data vectors to "close" your filled polygons. Although creating a

How can I change 'PlotStyle' property of a given boxplot figure?

风格不统一 提交于 2019-12-22 05:32:43
问题 Given a .fig file of a Matlab boxplot (i.e. underlying data not available), is it possible to change the PlotStyle attribute (from 'traditional' to 'compact')? 回答1: This question is kind of tricky because not like other graphic objects in Matlab, boxplot is a group of lines. As so, all the properties that are set while you create it are inaccessible (and in fact does not exist) after plotting. One option to deal with that is to create a 'dummy' boxplot, and then alter it to your data. Because

Expand (maximise) subplot figure temporarily — then collapse it back

筅森魡賤 提交于 2019-12-21 19:40:23
问题 Often in Matlab we would plot a figure with many subplot axes, but they are all tiny. In the prevalent UX paradigm, you would expect to be able to double-click such a small plot to have a closer look using the entire screen space. Typically this is the reason I avoid using subplot , but plot many individual figures instead — so I can move them around on the screen and double-click on their titlebars which (on Windows) maximises the figure to full screen. (Double-click again, and it returns to

2-D line gradient color in Matlab

北城余情 提交于 2019-12-21 18:29:47
问题 Is it possible to add gradient color to 2-D line in Matlab, especially when you have small number of data points (less than 10?), so the result would be similar to one in image below? 回答1: This is not difficult if you have MATLAB R2014b or newer. n = 100; x = linspace(-10,10,n); y = x.^2; p = plot(x,y,'r', 'LineWidth',5); % modified jet-colormap cd = [uint8(jet(n)*255) uint8(ones(n,1))].'; drawnow set(p.Edge, 'ColorBinding','interpolated', 'ColorData',cd) Which results in: Excerpted from

How to extract data from figure in matlab?

醉酒当歌 提交于 2019-12-21 14:59:04
问题 I have saved different Matlab plots in an unique .fig. The figure is like this: Now, I would like to introduce a filter in these plots to reduce the noises, but unfortunately I have lost the code that generates these signals. Is there a way to extract data of each signal in this figure? I tried this: open('ttc_delay1000.fig'); h = gcf; %current figure handle axesObjs = get(h, 'Children'); %axes handles dataObjs = get(axesObjs, 'Children'); %handles to low-level graphics objects in axes