matlab-figure

Connecting final and initial point in simple x-y plot (Plotting closed curve/polygon)

社会主义新天地 提交于 2019-12-30 08:41:55
问题 Say, for example, I had ... x = [1 1 2 2]; y = [1 2 2 1]; plot(x, y, 'b-'); I will get a plot with lines connecting the points (1,1), (1,2), and (2,2). Is there any way to connect the final point with the first, thus completing the square on the plot? I'm also pulling in lines of text with points, so simply adding another point 1,1 is not an option. 回答1: impoly can be useful, however, it creates a modifiable curve which is slower than plot. You can write a simple function for that: function

Connecting final and initial point in simple x-y plot (Plotting closed curve/polygon)

一世执手 提交于 2019-12-30 08:41:10
问题 Say, for example, I had ... x = [1 1 2 2]; y = [1 2 2 1]; plot(x, y, 'b-'); I will get a plot with lines connecting the points (1,1), (1,2), and (2,2). Is there any way to connect the final point with the first, thus completing the square on the plot? I'm also pulling in lines of text with points, so simply adding another point 1,1 is not an option. 回答1: impoly can be useful, however, it creates a modifiable curve which is slower than plot. You can write a simple function for that: function

Make squared in legend instead of lines Matlab

跟風遠走 提交于 2019-12-29 08:49:06
问题 I have the following code, which plots a 'map' using imagesc, and provides a legend, see output attached. I am trying to replace the lines in the legend with solid squares. My attamps to far leave the lines and ad hollow squares (including a random square in the top left corner of the figure) figure(6) imagesc(lut) title('Ditribution of Land use Types') ylabel('Longitude') xlabel('Latitude') caxis([0, 7]) myColorMap = jet(6); imagesc(lut, 'AlphaData', ~isnan(lut)) colormap(myColorMap); L =

How I obtain bars with function bar3 and different widths for each bar?

為{幸葍}努か 提交于 2019-12-29 06:47:29
问题 I have the code: values = [1.0 0.6 0.1; 0.0 1.0 0.3; 0.9 0.4 1.0]; h = bar3(values); shading interp for i = 1:length(h) % Get the ZData matrix of the current group zdata = get(h(i),'Zdata'); set(h(i),'Cdata',zdata) end set(h,'EdgeColor','k') view(-61, 68); colormap cool colorbar And this is what the figure looks like: I want to obtain different widths for each bar dependent on the height of the bar. What I want looks like a picture in http://www.sdtools.com/help/ii_mac.html. blah http://www

How to import non-comma/tab separated ASCII numerical data and render into vector (in matlab)

心已入冬 提交于 2019-12-25 16:08:15
问题 I want to import 100,000 digits of pi into matlab and manipulate it as a vector. I've copied and pasted these digits from here and saved them in a text file. I'm now having a lot of trouble importing these digits and rendering them as a vector. I've found this function which calculates the digits within matlab. However, even with this I'm having trouble turning the output into a vector which I could then, for example, plot. (Plus it's rather slow for 100,000 digits, at least on my computer.)

Marking peaks in an ECG signal

雨燕双飞 提交于 2019-12-25 08:03:06
问题 I am working on ECG signal processing. I am using the MIT-BIH Arrhythmia database found here. After loading the signal, I marked the R peaks correctly. Then I was trying to extract QRS complex, but I couldn't. I want to make marks on peaks like in this image: . . . . . . . Here is my code: clear all; clc; close all; load ('G:\1.Thesis\data set\100\100m') %% Remove base & gain %%figure (1) val = (val - 1024)/200; ECGsignal = val(1,1:3600); SAMPLES2READ = 3600; time = (0:length(ECGsignal)-1)

Overlaying one image on another gives blue boxes instead of image - MATLAB

房东的猫 提交于 2019-12-25 07:59:18
问题 I am trying to overlay one image on top of another in MATLAB. I checked out Superimpose two images in MATLAB for an answer. But the issue is that the overlayed images are being shown as blue boxes on the original image, instead of the actual image. The incorrect output is shown here http://imgur.com/R1QZh32. The code I am using is a = 0.2; tform = affine2d([1 0 0; a 1 0; 0 0 1]); B = imwarp(z,tform, 'FillValues',255); B = ~B; figure; imshow(B); h = imagesc([X1 X2], [Y1 Y2], B); set(h,

Replace a certain color range in an image with another color Matlab

て烟熏妆下的殇ゞ 提交于 2019-12-25 07:48:48
问题 how to replace the pixels having a certain RGB range not just a specific value as shown in this question like for example pixels with R ranging from 140-150, G ranging from 50-55 and B ranging from 61-70 , with another single value like (150,57,80). If anyone could please advise. 回答1: This is also a modification to the answer I provided in the other question you posted earlier. You simply change the logical mask calculations so that we search for a range of red, green and blue values. As such

How to set uicontextmenu for contourf (MATLAB2014b)

天涯浪子 提交于 2019-12-25 04:13:31
问题 Originally I asked why pcolor and contourf don't work with this method, and I assumed they were symptoms of the same problem. This is not true, hence the new question. Why does this not work with contourf? (and how do i get it to work?) axes; stuff = uicontextmenu('Parent',ancestor(axes,'figure')); stuffm = uimenu('Parent',stuff,'Label','Change something'); x = randn(10); h = contourf(x); % pcolor works! contourf does not %h = pcolor(x) set(h,'uicontextmenu',stuff); 回答1: You're trying to

Creating graphs that show the distribution in space of a large number of 2D Random Walks at three different time points

我与影子孤独终老i 提交于 2019-12-25 03:58:10
问题 So essentially I have this code here that I can use to generate a 2D Random Walk discretely along N number of steps with M number of walkers. I can plot them all on the same graph here. clc; clearvars; N = 500; % Length of the x-axis, also known as the length of the random walks. M = 3; % The amount of random walks. x_t(1) = 0; y_t(1) = 0; for m=1:M for n = 1:N % Looping all values of N into x_t(n). A = sign(randn); % Generates either +1/-1 depending on the SIGN of RAND. x_t(n+1) = x_t(n) + A