matlab-figure

How to draw an arrow in Matlab?

眉间皱痕 提交于 2019-11-26 17:45:27
问题 I'm trying to draw an arrow in matlab graph, without any success. Code example: function [ output_args ] = example( input_args ) figure ('Name', 'example'); x = [10 30] y = [10 30] xlim([1, 100]) ylim([1, 100]) arrow (x, y) ??? end Is there any function in matlab that can draw arrow ? Thanks 回答1: You can use the (well-documented) DaVinci Draw toolbox (full disclosure: I wrote/sell the toolbox, though arrows are free). Example syntax and example output are below. davinci( 'arrow', 'X', [0 10],

Multiple plots in one figure

荒凉一梦 提交于 2019-11-26 17:38:11
问题 I have the following code and I want to combine phase space plots into one single figure. I have coded the functions, but I don't know how to make MATLAB put them into one figure. As you see, it is the variables r , a , b , and d that changes. How do I combine them? I also would like to plot the vector field of these phase space plots using the quiver command, but it just does not work. %function lotkavolterra % Plots time series and phase space diagrams. clear all; close all; t0 = 0; tf = 20

Automatically plot different colored lines

巧了我就是萌 提交于 2019-11-26 16:56:47
I'm trying to plot several kernel density estimations on the same graph, and I want them to all be different colors. I have a kludged solution using a string 'rgbcmyk' and stepping through it for each separate plot, but I start having duplicates after 7 iterations. Is there an easier/more efficient way to do this, and with more color options? for n=1:10 source(n).data=normrnd(rand()*100,abs(rand()*50),100,1); %generate random data end cstring='rgbcmyk'; % color string figure hold on for n=1:length(source) [f,x]=ksdensity(source(n).data); % calculate the distribution plot(x,f,cstring(mod(n,7)+1

How should I update the data of a plot in Matlab?

送分小仙女□ 提交于 2019-11-26 15:19:49
Suppose that I want to update a plot with a new data. What method should I choose? Set the XDataSource property to some name, update the variable, and call refreshdata Erase the original plot , and call plot command again. Use Set('Xdata',...') Andrey Rubshtein Short answer : always use Set('Xdata',...') . Example code: function PlotUpdate() x = 0:.1:8; y = sin(x); h = plot(x,y); y = sin(x.^3); set(h,'XData',x,'YData',y); end Long answer: There are three relevant measures by which one should choose the best method. Code clarity - How easy it is for someone to read your code? Runtime - How

Matlab: How to assign different colormaps/colorbars to different surfaces in the same Figure

安稳与你 提交于 2019-11-26 12:44:54
问题 I am fairly new to Matlab and have a few questions. I got two surfaces and a plane in the same figure. I want to use different colormap and colorbar for b and another colormap and colorbar for c. s is fixed color so it\'s not a problem. Let me try to explain what I am trying to achieve: cmap1=colormap(topobathy) -->cmap1 is 64x3 double as expected cmap2=colormap(redwhitegreen) create cdata1 using cmap1 (this is the first part I cannot figure out, how to scale z data using cmap1, by default

Automatically maximize a figure

一世执手 提交于 2019-11-26 12:06:52
问题 I am creating some figures in MATLAB and automatically save them to files. The problem that by definition the images are small. A good way to solve my problem by hand is to create an image (figure), maximize it, and save to a file. I am missing this step of automatically maximize a figure. Any suggestions? Up till now I only found this: http://answers.yahoo.com/question/index?qid=20071127135551AAR5JYh http://www.mathworks.com/matlabcentral/newsreader/view_thread/238699 but none are solving my

How do I get the handles of all open figures in MATLAB

怎甘沉沦 提交于 2019-11-26 12:03:35
问题 I have nine open figures in matlab (generated by another function) and I want to print them all to file. Does anyone know how to grab the handles of all open figures in MATLAB? I know about gcf but it doesn\'t seem to do what I want. 回答1: There are a few ways to do this. One way to do this is to get all the children of the root object (represented in prior versions by the handle 0 ): figHandles = get(groot, 'Children'); % Since version R2014b figHandles = get(0, 'Children'); % Earlier

Setting graph figure size

自作多情 提交于 2019-11-26 11:58:33
问题 All I want to do is make the width greater and the height smaller. I\'m just doing raster plots but this question applies to any MATLAB figure . I can manually resize it using the figure directly when it\'s created but I want the program to spit it out in the right size to start with. 回答1: This could possibly help you? hFig = figure(1); set(hFig, 'Position', [x y width height]) 回答2: Write it as a one-liner : figure('position', [0, 0, 200, 500]) % create new figure with specified size 回答3:

How to generate a non-linear colormap/colorbar?

 ̄綄美尐妖づ 提交于 2019-11-26 11:33:50
问题 I would like to show a non-uniform colorbar as in the first picture. I have tried the code below. \'mycamp4\' is a colormap manually saved. The result is shown as the second figure. The number 0.1 and 1.5 will be too closed too see. How can I make the colorbar like in the first picture? v = [0.1 1 1.5 5 7.5 10 30]; v_2 = [0.1 1.5 5 7.5 10 30]; contourf(X,Y,pdf_normal\',v); h = colorbar; load(\'MyColormaps\',\'mycmap4\'); set(gcf,\'Colormap\',mycmap4); set(h, \'YTick\', v_2) Picture 1: Picture

Change color of 2D plot line depending on 3rd value

强颜欢笑 提交于 2019-11-26 11:25:01
问题 I have a data set that looks like this 140400 70.7850 1 140401 70.7923 2 140402 70.7993 3 140403 70.8067 4 140404 70.8139 5 140405 70.8212 3 Where the first column corresponds to time (one second intervals between data points) and will be on the x axis, the second column corresponds with distance and will be on the y axis. The third column is a number (one through five) that is a qualification of the movement. I want to make a plot that changes the color of the line between two points