matlab-figure

Making Particles Move Randomly Within A Circle [closed]

二次信任 提交于 2019-12-01 15:32:10
I am attempting to make plotted points move around within a circle of a known radius and center. At the moment I am able to generate points within the boundary, but now I need to make them move. I have the following script to generate the initial locations of the particles. function [particle_gen] = generate(n,centre,radius) %generates n particles in a circle with specified centre and radius angle = 2 * pi * rand(n,1); r = radius * sqrt(rand(n,1)); X = r.*cos(angle) + centre(1); Y = r.*sin(angle) + centre(2); plot(X,Y,'.k') end I want to animate them so that the particles travel in a straight

Tight subplot with colorbars and subplot's 3rd parameter in Matlab?

旧街凉风 提交于 2019-12-01 14:58:06
I would like to have a tight subplot i.e. minimum spacing between figures in the subplot where you have subplot's 3rd parameter i.e. you can decide where the picture is going to be i.e. easy to move between subplot and new_tight_subplot , and you can use it with colorbars. I have profiled the most popular tight subplots in FileExchange of Matlab. None (etc most popular here Pekka's version) can pass the following code data=randi(513,513); ax1=subplot(2,1,1); plot(mat2gray(pdist(data, 'correlation'))); cbar1=colorbar(ax1); axis(ax1, 'square'); xlim([0 size(mat2gray(pdist(data, 'correlation')),2

How to concatenate these subplots on one graph?

余生颓废 提交于 2019-12-01 14:53:33
Here is the a simpler version of my code. ..... ch_array = [36, 40, 44, 48, 149, 161]; figure; for i=1:length(ch_array) ch = ch_array(i); subplot(3, 3, i); eval(sprintf('plot(mean_a_%d_f, ''r'')', ch)); hold on; eval(sprintf('plot(mean_b_%d_f, ''b'')', ch)); xlabel('Subcarrier (f)'); ylabel('Absolute values'); eval(sprintf('title(''Channel: %d'')', ch)); end ..... The mean_a and mean_b depend on the ch_array so that as a result, there are mean_a_36_f , mean_a_40_f ,..., mean_a_161_f and the same thing with the mean_b . This for loop plots graphs according to ch_array , the following figure: As

How to remove Rho labels from Matlab polar plot?

给你一囗甜甜゛ 提交于 2019-12-01 14:22:30
In my polar plot in Matlab, I have default labels for Theta (0, 30, 60, .., 330) and Rho (20, 40, .., 100). I can remove Theta label using command set(findall(gca, 'String', '0'),'String', ' '); Please advice how to remove Rho labels (20, 40, .., 100) from the figure. angainor To remove all labels simply type delete(findall(gcf,'type','text')); Since the polar plot labels are hidden text objects placed around on the plot, you can not simply find them by accessing axes. To remove only some of them you will need to explicitly find the text objects containing those particular labels you want to

How to concatenate these subplots on one graph?

空扰寡人 提交于 2019-12-01 13:36:22
问题 Here is the a simpler version of my code. ..... ch_array = [36, 40, 44, 48, 149, 161]; figure; for i=1:length(ch_array) ch = ch_array(i); subplot(3, 3, i); eval(sprintf('plot(mean_a_%d_f, ''r'')', ch)); hold on; eval(sprintf('plot(mean_b_%d_f, ''b'')', ch)); xlabel('Subcarrier (f)'); ylabel('Absolute values'); eval(sprintf('title(''Channel: %d'')', ch)); end ..... The mean_a and mean_b depend on the ch_array so that as a result, there are mean_a_36_f , mean_a_40_f ,..., mean_a_161_f and the

How to remove Rho labels from Matlab polar plot?

我怕爱的太早我们不能终老 提交于 2019-12-01 12:45:02
问题 In my polar plot in Matlab, I have default labels for Theta (0, 30, 60, .., 330) and Rho (20, 40, .., 100). I can remove Theta label using command set(findall(gca, 'String', '0'),'String', ' '); Please advice how to remove Rho labels (20, 40, .., 100) from the figure. 回答1: To remove all labels simply type delete(findall(gcf,'type','text')); Since the polar plot labels are hidden text objects placed around on the plot, you can not simply find them by accessing axes. To remove only some of them

Why is subplot much faster than figure?

你离开我真会死。 提交于 2019-12-01 11:42:32
I'm building a data analysis platform in MATLAB. One of the system's features need to create many plots. At any given time only one plot is available and the user can traverse to the next/previous upon request (the emphasis here is that there is no need for multiple windows to be open). Initially I used the figure command each time a new plot was shown, but I noticed that, as the user traverse to the next plot, this command took a bit longer than I wanted. Degrading usability. So I tried using subplot instead and it worked much faster. Seeing this behavior I ran a little experiment, timing

Plotting brownian motion matlab

删除回忆录丶 提交于 2019-12-01 11:23:23
问题 First of all, I just want to say that I'm not that used to using matlab, but I need for an assignment, I'm supposed to create a "brownian movement". My code is currently looking like this: clf hold on prompt = 'Ge ett input'; size = input(prompt) ; numParticles = input('Ange antal partiklar'); axis([-size size -size size]); Part = []; color = 'brkgmyco'; for i = drange(1:numParticles) Part = [Part [0;0]]; end for i = drange(1:200) dxdy = randn(2,numParticles); k = Part Part = Part + dxdy; My

Matlab bars: changing the color of the bar and the space between bars and axes

流过昼夜 提交于 2019-12-01 11:18:46
I have a tricky question, which I think cannot be simply answered. I have a large data table and want to save bar charts for each 2 corresponding mean values. I already did that with "for loop", but I cannot set different colors to my bars and cannot set proper spaces between bars and axes. That's the simplest example: k = [2 5] bar(k) Matlab thinks about those data [2 5] as about one "group" and it does not give a possibility of changing color for only one bar. Of course, when we have different "groups", colors are changeable. y = bar([1 2 3; 4 5 6]); y(2).FaceColor = 'red'; But what about my

Why isn't this MATLAB class holding on to its properties?

蹲街弑〆低调 提交于 2019-12-01 11:16:39
There must be something very simple that I'm missing here. I have a MATLAB class which creates a figure containing two push-buttons, each button calls the same function, but the handles for those buttons aren't retained within that function, and I don't know why. Here's the class, simplified... classdef Test properties Figure ButtonA ButtonB end methods function app = Test() app.Figure = figure(); app.ButtonA = uicontrol('Style', 'pushbutton', ... 'String', 'Button A', ... 'Position', [10, 10, 100, 20], ... 'Callback', @app.PressButton); app.ButtonB = uicontrol('Style', 'pushbutton', ...