matlab-figure

How to make a graph of a three-branches function in matlab

时光总嘲笑我的痴心妄想 提交于 2019-12-19 11:20:05
问题 How can I make this function's graph in Matlab, so that its body is depicted in the same graph (plot or subplot)? t0=0.15 x(t)= 1, if 0<=t<(t0/2) -2, if (t0/2)<=t<=(3/2)*t0 0, else 回答1: The real question you should be asking is "How to define a function that has branches?", since plotting is easy once the function is defined. Here's a way using anonymous functions: x_t = @(t,t0)1*(0<=t & t<t0/2)-2*(t0/2<=t & t<=(3/2)*t0); %// the 1* is redundant, I only %// left it there for clarity Note that

Bounding box using MATLAB for the image

强颜欢笑 提交于 2019-12-19 10:04:38
问题 I am trying to draw a bounding box around the white blob in the image below: I did like this: bw = imread('box.jpg'); bw=im2bw(bw); imshow(bw) L = bwlabel(bw); s = regionprops(L, 'Area', 'BoundingBox'); s(1); area_values = [s.Area]; idx = find((100 <= area_values) & (area_values <= 1000)); % list of all the objects %whose area is between 100 and 1000 bw2 = ismember(L, idx); %construct a binary image containing all the objects whose %area is between 100 and 1000 by passing L and idx to

Adjusting size of plot in Matlab so that graph does not get cut off by edge of plot window

对着背影说爱祢 提交于 2019-12-19 04:36:47
问题 I've created a plot in Matlab, but unfortunately the side of the plot is cut off by the plotting window. Here is the code that I've used to create the plot: % create a plot with dots and with bold sides point = num(:, 1); depth = num(:, 2); hfig = plot(point, depth, '-s', 'Color', 'k', 'MarkerFaceColor', 'k', 'MarkerEdgeColor', 'k', 'MarkerSize', 10); % make the outside of the graph bold set(gca, 'LineWidth', axis_size); set(gca,'FontSize', ticksize, 'FontName', fontname); set(gca, 'Position'

Modify x-axis position

我与影子孤独终老i 提交于 2019-12-19 04:02:16
问题 When you use plot function in Matlab, you are presented with y and x axis on the left and at the bottom respectively. But I'd like the x-axis to strike through in the middle of the figure with the scales and numbers like so: I beg a pardon for my amateur paint skills. But basically I want the x-axis to move to the top for example and I want to have numbers there and those small bumps like indicated on the red line but all the way through to the right, but I do not want a number under each

How To Put String Labels on Contours for Contour Plots in MATLAB

我的未来我决定 提交于 2019-12-19 03:21:44
问题 I am wondering if it is possible to label the contours of a MATLAB contour plot with a set of user-defined strings? I am currently using the following code snipper to produce a labelled contour plot: %Create Data X = 0.01:0.01:0.10 Y = 0.01:0.01:0.10 Z = repmat(X.^2,length(X),1) + repmat(Y.^2,length(Y),1)'; %Create Plot hold on [C,h] = contourf(X,Y,Z); %Add + Format Labels to Plot hcl = clabel(C,h,'FontSize',10,'Color','k','Rotation',0); set(hcl,'BackgroundColor',[1 1 1],'EdgeColor',[0 0 0],

How to draw good looking arrows in Matlab?

扶醉桌前 提交于 2019-12-19 02:58:41
问题 I have been trying to draw arrows in Matlab in my figure but they all look terrible. Also, I want my arrowhead to be a solid triangle, not a V. I tried using the packages available on the Matlab File Exchange: arrow, arrows, arrows3, and probably at least one other one. I even tried manually creating an arrow in the Matlab figure editor, but when I adjust the line width, the arrow looks like this: I used the annotation command to create the arrow above: annotation(gcf,'arrow',[0.621875 0

Matlab bar plot grouped but in different y scales

允我心安 提交于 2019-12-18 17:50:10
问题 I have two sets of data, and I want to plot using bar graph. But the problem is these two sets of data are at quite different scale. If I just use the bar(A) , it would look like this: grouped but the second data set is barely visible because the scale. However, if I use the plotyy(x,y1,x,y2) , the plot will be like this: two sets of data are in different scale, but the bar graphs are not grouped, the second data sets overlaps to the first. So I am wondering if there is a way to plot the bar

drawing 3d contour plot from 3d vector

给你一囗甜甜゛ 提交于 2019-12-18 09:40:06
问题 I want to draw a contour plot for 3D data. I have a force in x,y,z directions I want to plot the contour3 for that the dimensions of the Fx = 21x21X21 same for Fy and Fz I am finding force = f*vector(x,y,z) Then Fx(x,y,z) = force(1) Fy(x,y,z) = force(2) Fz(x,y,z) = force(3) I did the following but it is not working with me ?? why and how can I plot that FS = sqrt(Fx.^2 + Fy.^2 + Fz.^2); x = -10:1:10; [X,Y] = meshgrid(x); for i=1:length(FS) for j = 1:length(FS) for k=1:length(FS) contour3(X,Y

Matlab colorbar indicator which dynamical change

笑着哭i 提交于 2019-12-18 09:37:15
问题 Running the next code I get a black bar in the colorbar that change in every loop. If I change the limits, from 200 to 2000, and run for y= x.^2 +10*i +1000 , 2nd version, then the bar sometimes appears , others not. Is anyone knows why? and how can make it work? Is it possible to have a dynamic colorbar? i.e. if we plot a sound output, to show as colorbar the sound level in dB EDITED: x = 1:10; figure; for i = 1:10 y= x.^2 +10*i; % y= x.^2 +10*i +1000; % 2nd version plot(x,y,'-r'); hold on;

save GUI figure in matlab

陌路散爱 提交于 2019-12-18 09:34:27
问题 let us consider following program for graphical user interface function varargout = quadratic(varargin) % QUADRATIC MATLAB code for quadratic.fig % QUADRATIC, by itself, creates a new QUADRATIC or raises the existing % singleton*. % % H = QUADRATIC returns the handle to a new QUADRATIC or the handle to % the existing singleton*. % % QUADRATIC('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in QUADRATIC.M with the given input arguments. % % QUADRATIC(