matlab-figure

How to plot a figure similar to the one produced by lassoPlot.m to specify a regularization parameter?

不问归期 提交于 2019-12-02 05:19:27
I am trying to apply a regularized optimization other than Lasso. How can I plot the figure similar to the one produced by lassoPlot.m included in MATLAB as shown below if all data needed can be provide? How to plot the I -shaped lines? I read the lassoPlot.m but cannot find out how it is done. If I had to create a plot like this manually, I'd do something like this: function q53809665 DATASET = [ 0.601240818 459.5714648 6.549320679 0.38951982 407.6789162 6.915203670 0.250128593 366.9277664 8.668936114 0.162048287 339.5657219 9.739510946 0.104984588 307.3415556 8.790018144 0.067415433 285

How can I multiple plot in one figure at Matlab?

有些话、适合烂在心里 提交于 2019-12-02 05:13:41
Hi I'm trying to implement as following code. plot(bins,r); plot(bins,g); plot(bins,b); But I want to plot in one figure. Is there any way? For multiple plots in the same figure and not the same axis. You have to use subplot(x,y,z). The first argument 'x' is the number of plot you want to produce, in your case 3. Second 'y' just adjusts the size of the plots, you can use 1. The third 'z' is the position of the plot, whether a certain plot comes first, second or third. subplot(3,1,1) plot(bins,r); subplot(3,1,2) plot(bins,g); subplot(3,1,3) plot(bins,g); To distinguish between all three plot

How do I fill in the area between two lines and a curve that's not straight in MATLAB (the region is not a polygon)

人走茶凉 提交于 2019-12-02 05:08:39
Using matlab's FILL function creates a filled region confined by a polygon with straight edges: Unfortunately this leaves a small white region in the figure above, because the boundary of the region I want filled in is not a straight-edged polygon, but rather has a curved boundary on the left side. I have a curve (nearly parabolic but not exactly), and I want to fill in the region between two horizontal lines AND the curve itself. I also looked into the MATLAB function IMFILL, but with no luck. What you need to do is make a polygon with more corners, so that it fits the curve more smoothly: %#

matlab plot image as background to graph

假如想象 提交于 2019-12-02 05:08:32
问题 I have an image that I would like to set as the background of plot I am making. However it plots it so that the image taks up the axis([0 1000 0 1000]) while the axis for my graph is much smaller: ([24.5 24.6 67 67.1]). How do I align it so that the image is on the same scale as the graph? I am performing the following commands: h = figure; hold on voronoi(lats,longs); I=imread('my_fig.png'); hi = imagesc(I); set(hi,'alphadata',.5); 回答1: You can just call image with the right x and y vectors,

Plotting piecewise function

被刻印的时光 ゝ 提交于 2019-12-02 04:46:53
I have a solution to a differential solution but the issue is that I have different solutions in different intervals. For examle: x_1(t) when t belongs to [0,t_1] x_2(t) when t belongs to [t_1,t_2] x_3(t) when t belongs to [t_2,t_3] Now I need to plot these graphs so that they look like they have a single function i.e just immediately after the first graph x_1(t) until t_1 , I need the other graph x_2(t) and so on. Is it possible in Matlab? You can use plot with multiple inputs to plot them altogether: % the functions: x_1 = @(t) 2.*t; x_2 = @(t) 5.*t; x_3 = @(t) 7.*t; % the transition points:

How to properly display TeX strings in axes' datatips? (MATLAB hg2)

孤者浪人 提交于 2019-12-02 04:28:58
问题 I have recently tried to run an old piece of code (written on hg1) on a new version of MATLAB (2015a) that has hg2. I used to be able to do the following (according to the "gnovice-Amro" method): function output_txt = customDatatip(~,event_obj) % Display the position of the data cursor % obj Currently not used (empty) % event_obj Handle to event object % output_txt Data cursor text string (string or cell array of strings). hFig = ancestor(event_obj.Target,'figure'); %// I don't trust gcf ;)

Bounding box of an object in an image Matlab

不羁岁月 提交于 2019-12-02 04:22:24
问题 I want to get the object's bounding box positions (x, y, width and height) in the image and save it to a text file. As shown in the below image. So if anyone could please advise. The image can be found here 回答1: Assuming you have read the image using imread , this should work: bwImage=~im2bw(img,0.98); %making gray pixels white and (almost) white pixels black bndBox=regionprops(bwImage,'BoundingBox'); bndBox will have top-left corner of the bounding box and its width and height stored in the

Re-use the view output matrix in Matlab

浪尽此生 提交于 2019-12-02 04:01:58
问题 In Matlab, I create a fairly complicated 3D plot, then manipulate the view option by hand up to a point where I am happy with what I see (below). How can I reuse the parameters of the final view? I can get the output of the view command which is a 4 by 4 matrix, but the latter does not seem to be reusable? 回答1: In order to get something out of view that you can then pass to view to reconstruct the viewpoint, you need to specify two outputs to view which will yield the current azimuth and

How to have a common label for all x and y axes in case of subplots?

纵然是瞬间 提交于 2019-12-02 03:52:27
I have used the following loop to get subplots: for j=1:19; Aj=B(j,:); subplot(5,4,j); plot(Aj,h) end For all these subplots, I need to have only one x-label and one y-label. How to do this? Also how to insert legend to all the subplots? You can use suplabel from the FileExchange to have combined x and y label for all subplots. Example: subplot(1,2,1); plot(randperm(40)); hold on; plot(randperm(40)); %Plotting some random data legend('show') %To show the legend subplot(1,2,2); plot(randperm(40)); hold on; plot(randperm(40)); %Plotting some random data legend('show') %To show the legend %Using

In Matlab, how to draw lines from the curve to specific xaxis position?

社会主义新天地 提交于 2019-12-02 03:51:35
I have a spectral data (1000 variables on xaxis, and peak intensities as y) and a list of peaks of interest at various specific x locations (a matrix called Peak) which I obtained from a function I made. Here, I would like to draw a line from the maximum value of each peaks to the xaxis - or, eventually, place a vertical arrow above each peaks but I read it is quite troublesome, so just a vertical line is welcome. However, using the following code, I get "Error using line Value must be a vector of numeric type". Any thoughts? X = spectra; [Peak,intensity]=PeakDetection(X); nrow = length(Peak);