FAQ Database Discussion Community


How to plot dates against prices

matlab,plot,matlab-figure
I have a dataset with in the first column dates in the form of 'dd-mm-yy' (so for example (15-3-1978) and in the second column prizes. Now I want to plot dates against prices, but unfortunately plot(dates,prizes) doesn't work. Can somebody help me out? ...

Switching values to plot using keyboard input

matlab,octave,matlab-figure
I have sets of data in a matrix. I want to plot on set and then use a keyboard input to move to another one. It's simply possible this way: for t=1:N plot(data(:,t)) pause end but I want to move forward and backward in time t (e.g. using arrows). OK,...

Add a vector as legends in Matlab

matlab,matlab-figure
I have a vector whose entries I want to be the titles of the graphs which of my plot. How do I do that? I know that I can only add 1 legend to a plot. n=[2 4 6 8 10]; legend(int2str(n)); and it should appear as 5 different legends...

Dividing matlab plot into grids

matlab,signal-processing,matlab-figure
I have two different functions of time x(t) and y(t). I want to plot x(t) vs y(t) in matlab . The plot needs to be divided into a 40x40 grid stretching from min and max values of signal in each direction. I then need to calculate the number of grid...

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

matlab,textbox,matlab-figure,undocumented-behavior,matlab-hg2
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...

Matlab contour plot smooth colors

matlab,plot,matlab-figure,contour
Could you tell me how to plot in Matlab figure such as below (smooth transition of colors)? Function countour allows only to create plot with contour lines which doesn't provide enough information to me. ...

Matlab multidimensional scatter [duplicate]

matlab,graph,matlab-figure,scatter-plot
This question already has an answer here: 3D scatter plot with 4D data 2 answers I have a an nx4 matrix where each row is an observation. The three three columsn represent by variables, and the fourth a 'fitness' parameter. I would like to show this in a 3D...

Greek symbols in labels for bar chart in MATLAB

matlab,latex,bar-chart,matlab-figure
I would like to use greek symbols in the ylabels for my barh() chart. I tried the following but it didn't really work: tplot = barh(mdata, 'BarWidth', 0.3); set(gca,'xgrid','on') lbl = {'$$\hat{\sigma}_1$$', '$$\hat{\sigma}_2$$', '$$\hat{\sigma}_3$$'}; box off set(gca,'yticklabel',lbl) h=findobj(gca,'type','text'); set(h,'Interpreter','latex') I also tried: set(gca,'TicklLabelInterpreter', 'tex') When I do get(gca), the property...

Custom colors for group of bars in Matlab

matlab,matlab-figure
I want to have custom colors for a group of bars in Matlab bar plot. Like the one showed here but with different colors. How can I do this? I tried to use the following code but it shows stacked bars instead of the groups. xdata = [1 2 3];...

Matlab - axes properties

matlab,matlab-figure
How to make x-axis and y-axis cross at origin and label the axes in both sides, i.e 'xlabel' in +ve x-axis and 'xlabel' in -ve x-axis and similarly for 'ylabel'.

How to convert a point in image imrotated with loose option to a point in image imrotated with crop option in Matlab?

image,matlab,image-processing,matlab-figure,coordinate-systems
How to find the relation between image imrotated with loose option Image 1 and image imrotated with crop option Image 2 ? the angle of rotation is not necessary -45° ... I = imread('cameraman.tif'); Im1 = imrotate(I,-45); % bbox option sets to 'loose' by default Im2 = imrotate(I,-45,'nearest','crop'); % bbox...

I don't get the use of axis(1:2) in Matlab?

matlab,image-processing,matlab-figure
I am in front of the following (modified) matlab code : figure(3); subplot(2,3,2); axises=axis; center = [mean(axises(1:2)),mean(axises(3:4))]' my problem is : Why did he use axises and not keep using axis ? What does axises(1:2) do ? I have checked the axis documentation, but there is no mention to something...

How to make differently named movies in a for-loop in matlab

matlab,matlab-figure
Say i have a for-loop. count=1; for t=1:20 while(true) figure(); (do sth...) view([-90 -90]) pause(0.01) M(count)=getframe; count=count+1; end movie2avi(M, 're.avi'); end Inside the for-loop there is a while loop where i am making my movie. But in each iteration of for loop one movie is made. I want to store...

Creating a hexplot

r,matlab,matplotlib,gnuplot,matlab-figure
I am trying to create a figure like the one depicted in the third column of the following image: Link for the image in case of backup. Basically I have x and y positions of 200 particles and I have the MSD data for these 200 positions. I'd like MSD...

How can I make my plots look prettier (including fonts, label, etc )?

matlab,plot,matlab-figure
I am trying to obtain very nice plots for my presentation below is a code that I used to plot clear all clc close all syms v omegat= -2:0.000001:2; Nt=32; gainfuc = (1/Nt)*exp(1i*pi*omegat*(Nt-1)/2).*sin(pi*Nt*omegat/2)./sin(pi*omegat/2); gainfuc(omegat == 0) = 1; G = (omegat < 2/Nt).*(omegat > -2/Nt); plot(omegat,abs(gainfuc)) syms t hold on...

Resize/Change Figure Axis Range in Matlab

matlab,resize,matlab-figure,figure,axes
I have a button in my Matlab GUI to open up an axes plot in a new figure, here is my code: fig=figure; set(fig, 'Position', [100, 100, 1049, 895]); h=handles.axes2; copyobj(h,fig); set(gca,'units','pix') set(gca,'units','norm') However, the axes is quite small in the new figure: But when I try to add this...

colormap for imshow in GUIDE axes object

matlab,matlab-figure,matlab-guide
I have using GUIDE to display raster data inside of a axes object. But I want to colormap to be the 'colorcube' map. Right now I set this with two lines: function mapImage(data, box) low = min(min(data)); high = max(max(data)); imshow(data, [low high], 'Parent', box); colormap(box, colorcube); Update: I do...

How do I make a Matlab plot fill the whole page?

matlab,matlab-figure
I want to make a plot in Matlab which is twice as tall as it is long. I tried following the advice of this question using Position and PaperPositionMode, like so: figure set(gcf,'PaperPositionMode','auto'); set(gcf, 'Position', [0 0 100 200]); barh(1:20); print('test', '-dpng'); Annoyingly, this resizes the paper size but not...

Change axis in polar plots in matlab to radians

matlab,matlab-figure,radians
So matlab rightfully uses radians for trigonometric functions and in the actual plotting of polar plots. However annoyingly it puts the angular axis in degrees, is there any way to change this?

non-homogenous grouped data in MATLAB plotyy()

matlab,matlab-figure
I have to plot 1 line plot and 3 grouped scatter plots in a single plot window. The following is the code I tried, figure; t1=0:0.1:10; X = 2*sin(t1); ts = 0:1:10; Y1 = randi([0 1],length(ts),1); Y2 = randi([0 1],length(ts),1); Y3 = randi([0 1],length(ts),1); plotyy(t1,X,[ts',ts',ts'],[Y1,Y2,Y3],'plot','scatter'); %plotyy(t1,X,[ts',ts',ts'],[Y1,Y2,Y3],'plot','plot'); The following are my...

Colorbar - axis ticks in Matlab

matlab,plot,colors,matlab-figure
I am using the code below d3 = vals; n = datesmonth; figure plot(n,d3); colormap(jet(12)); hold on plot(n, d3,'b-'); scatter(n, d3, [], RiskierInd, 'filled'); caxis([1 12]); colorbar('YTick',[1:12],... 'YTickLabels',{'Non-Durables','Durables','Manufacturing','Oil, Gas and Coal ','Chemicals','Technology','Telephone & TV','Utilities','Wholesale and Retail','Health','Finance','Other'}) datetick('x','mm-yyyy') to produce this figure I have two quick questions: Is it possible to...

imread function doesn't work in matlab

matlab,image-processing,matlab-figure
I am new to Image processing and learning matlab. Actually till now I have used matlab cloud version where uploading an image was directly possible and didn't face any issue. But now I am facing an extreme problem of uploading an image in matlab offline version software. I imported an...

Drawing the top axis (box) line

matlab,matlab-figure,matlab-hg2
I have a plot with two lines and two different x-axis (different data units), which I plot like the following. My problem is that I would like to draw the top line of the box black as well (horizontally), and not leave it "open" like it is. It would be...

excessive green color extraction implementation

matlab,image-processing,matlab-figure
i want to segment image pixels into vegetation and Non vegetation. For this excessive green color extraction algorithm is developed.the algorithm is shown below. Outimage (x,y,z) = inimage (x,y,z) if { inimage (x,y,r) < (x,y,g) inimage (x,y,b) < (x,y,g) } outimage(x,y,z) = 0 otherwise* where outimage (x,y,z) is the output...

MATLAB imagesc: Use black as mid-color for value 0

matlab,matlab-figure,zero,colormap
I want to use imagesc to plot a quantity where all of positive, negative, and close-to-zero values are important. I want the close-to-zeros to be black, but there is no default colormap that provides such a feature. For example, using colormap(hot) assigns black to the lowest (in this case: negative)...

Filling the area between three curves in MatLab with Bold Plot

matlab,plot,matlab-figure
I am trying to make a graph similar to the one below: I have the plots for the lower bound of the graph, the median (bold line) and the upper bound. I tried working around with fill but it seems to create weird filled polygons. Also, how can I make...

Indicate name of filled areas inside area plot - Matlab?

matlab,matlab-figure
It's difficult to identify in this area plot each one of the many filled areas by just looking at the legend (it's like 16!). So, I was wondering if there's a way to place some sort of labels (with a pointer perhaps?) inside the plot that clearly identifies each filled...

Simultaneous interaction with 2 figures in MATLAB GUI

matlab,user-interface,matlab-figure,matlab-guide
I am writing a GUI in MATLAB (guide) where user will be shown 2 images(both images are positioned side by side in single gui window) from a series of images (but each drifted little bit) and will be allowed to select area of interest. I want user to select working...

What's wrong with my plot of a 3D seashell in Matlab?

matlab,matlab-figure
My task is to draw such seashell in Matlab. This is what it's supposed to look like: My code is s = linspace(0,2*pi); t = linspace(0,2*pi); [s, t] = meshgrid(s, t); n=2; a=15; b=500; c=10; X =a.*(1-(t./(2*pi))).*cos(n.*t).*(1+cos(s))+c.*cos(n.*t); Y =a.*(1-(t./(2*pi))).*sin(n.*t).*(1+cos(s))+c.*sin(n.*t); Z = b.*(t./(2*pi))+a.*(1-(t./2*pi)).*sin(s); surf(X,Y,Z ,'LineStyle','none','FaceLighting','phong','EdgeColor','none') colormap(jet) camlight right and this is...

How to define transparent element in colormap

matlab,matlab-figure,colormap
I would like to define a transparent color within the color map how do I do that? The reason I need this is that I have a multiple layers in my axes (produced both by imagesc and plot). I know I could simply first use imagesc and then plot but...

Difference in “polar” command in Matlab from 2013 version to 2015

matlab,matlab-figure
I wanted to remove the numbers from the polar plot so I used the following: myline = polar(txxx, pxxx); get handle of the data line set(0,'Showhiddenhandles','on') % to show hidden handles extrastuff = setdiff(get(gca,'children'),myline); delete(extrastuff) and it works in 2013b version but does not work in 2015 version. Can anyone...

How can I smooth a surface in MATLAB?

matlab,matlab-figure,surface
I have a surface in matlab which is plotted using the following code: [xi, yi] = meshgrid(S/K, days); vq = griddata(S/K, days, rbf/K, xi, yi,'natural'); mesh(xi,yi,vq) The resulting image is quite rough, and has lots of grid lines as there are roughly 200 data points in each vector. Is it...

MATLAB: plotting subplots in for loop

matlab,for-loop,plot,matlab-figure,subplot
I'm trying to plot several subplots in a single figure. The total number of subplots is dependent on the maximal value in a matrix: maximal value of 'i'. I'd like to plot two variables in two subplots below each other for every value of i :slagtijd_start & slagfrequentie_start So when...

Contour colors don't correspond to color bar when a surf plot is added

matlab,plot,matlab-figure,colorbar
Below is some code that recreates my problem as simplified as I can make it. It does a subplot with two plots, you'll notice the plot on the right (contour only) has the correct correlation between the contour colors and the color bar but when a surface is added (left...

Plot multiple functions on one figure

matlab,matlab-figure
I'm struggling to plot multiple functions on one figure. Here is the code that I have: syms t a; a=0.9514; F1=0.5*sqrt(3*t^2); F2=-0.28375*t^2+1.155*a*(t-a)+1; F3=1; E1=diff(F1,t); E2=diff(F2,t); E3=diff(F3,t); I want to plot E1, E2 and E3, each only within a certain range, to make a "composite" line. I've tried plotting with ezplot...

How do I create axes in Matlab for a non-current figure?

matlab,plot,matlab-figure,axes
I can create a new axes on the current figure: ax = gca; % or ax = axes; If I already have a handle to the figure I want to work with, I can set that figure as current and then create the axes: figure(h); ax = axes; But as...

Matlab Recreating freqz, normalizing x axis and getting half of plot

matlab,plot,matlab-figure
I have a function which is basically recreating the freqz command in matlab. I have figured out how to plot the entire transform of my frequency response, but I only need half of it, and I need to normalize it from pi to 1 (where 0:pi represents my x axis,...

Changing LineStyle in Matlab without change being ignored

matlab,plot,matlab-figure
I am attempting to make lines more easily distinguishable by changing the line styes. However, most of the style changes are being ignored by matlab for no apparent reason. As far as I can tell, only ':' is being acknowledged and shown; everything else just uses a solid line regardless...

How to plot a matlab function for different parameters using hold on command

matlab,plot,matlab-figure
I have a matlab function that contain some constant parameter, I want to draw that function, on say same figure, using hold on (probably) while changing the value of that constant. This my code: close all clear all clc m = 5; x = 1:1:10; y = m*x + 10;...

Copy values of an opened figure into a Matrix Matlab

matlab,matlab-figure
I have a saved matlab .fig file which has an image and I open the fig using openfig. I'm asking how I can copy the figure values in a matrix (lets say img which is 480x640 double)to start doing some processing on it. If anyone could please advise.

Matlab openfig to existing figure

matlab,matlab-figure,handle
When in Matlab I use openfig(filename); to open a saved figure, it always opens a new window. All the 'reuse' argument does is not load the file when it appears to already be open. However, I wish to open the file into a given figure, and just overwrite its contents....

One combined legend entry for multiple plots

matlab,plot,legend,matlab-figure
For some reason, I would like to plot the line and marker of the same data separately. data1 = (1:1:10)'; data2 = (1:2:10); figure(1); plot(data1,data1,'or'); hold on; plot(data2,data2,'-r'); legend('data'); However it will only display the legend for the first plot. And Matlab seems not to have option to manipulate the...

Unexpected colors in `surf` plot

matlab,matlab-figure
I'm trying to write a matlab code that will answer the following question: Using functions linspace,meshgrid,surf and dot operations, plot the surface of the cones: z=sqrt(x^2+y^2) and z=-sqrt(x^2+y^2). Use the vector form of the coordinate transformation x=rcos(θ),y=rsin(θ), where 0 ≤ θ ≤ 2π and 0 ≤ r ≤ 2. Make...

What does the index refer to when selecting a pixel on an image in Matlab?

matlab,image-processing,matlab-figure,dicom,figure
When looking at a single pixel of an image in Matlab, what does this index refer to? X/Y refer to the coordinates of the pixel, and RGB refers to the color, but any ideas on what the index is? To clarify, when I am viewing a figure in Matlab and...

Different Colour Scatter points without using Hold on (or all)

matlab,colors,matlab-figure,scatter-plot,scatter
I would like to create a scatter plot in MATLAB using three sets of data. X,Y and c. X and Y are to be their respective axis plots but c holds information (integer values) on each scatter points classification. I wish to make each classification plot as a separate colour....

Plotting multiple tracks (sequence of 2D points) on an image

matlab,matlab-figure
I have multiple tracks (a sequence of 2D points) which I want to plot over an image. For instance, in the example below I have 10 tracks, each having its own set of 3 points. I iterate over all tracks and plot each one of them individually. Note, that all...

Use MATLAB to prompt user to select a image file

matlab,image-processing,matlab-figure
I am trying to implement a function starting with prompting user to select an image and do some image operation. Here is my code: [FileName, Path] = uigetfile ('*.bmp; *.png; *.jpg','Select the secret image'); secretImg = FileName; R = secretImg(:,:,1); G = secretImg(:,:,2); B = secretImg(:,:,3); However, this prompt me...

Adding extra information to datapoints on a plot

matlab,plot,matlab-figure
THERE IS THE SOLUTION BELOW! This (x,y) value actually corresponds to a t value, which I want to see on the plot. What can I do? Clearly matlab has the ability to display multiple information in the datapoint box: just call it as "TimePlot(x,y,t)" and it will work. This code,...

re-plotting of data on same GUI axes in matlab

matlab,matlab-figure,matlab-guide
I am working with GUI in matlab and I have one axes to plot the data. I want to keep track what I have already plotted in order to re-plot it if needed on same axes and for this purpose, I have list box which holds names of data sets...

Using datetick with keepticks in MATLAB

matlab,datetime,matlab-figure
I'd like to display an array at length (24*60*60). The x axis is the time of a day. When I use the following code, x axis shows 00:00:00, 00:59:59, 01:59:59, ..., 23:59:59, but there is no plot on the figure. That is plot(1:length(A),A) has no effect. (I also tried turning...

Drawing 3-D RGB cube model with Matlab

matlab,matlab-figure
I wrote this code to draw an RGB cube, but it's color not exact as true? %Define a six row by four column matrix to define the six cube faces fm = [1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2...

align text with tab and insert in figure

matlab,matlab-figure
I want to add a description of a model in a separate subplot figure in Matlab. The description is formed by reading user input data which can have different length and I want it to be displayed aligned in columns, something like: player 1____Andrew______blue player 2____Bob_________green player 3____Johnathan___red (with spaces...

Subplots within a Tabbed figure

matlab,plot,matlab-figure,subplot
For the following script, the subplots/plots are going behind the tab, when executed. How can this be fixed? h.mainfig = figure(); h.tabgroup = uitabgroup(h.mainfig, 'Position', [.05 .1 .9 .8]); ntabs = 4; for ii = 1:ntabs h.tab(ii) = uitab(h.tabgroup, 'Title', sprintf('Tab_%i', ii)); for jj=1:2 ax(jj)=subplot(2,1,jj);plot(1:10,sin(1:10)); end linkaxes(ax,'x'); end ...

Matlab: Format the decimals in contour labels

matlab,matlab-figure
I want to cut the number of decimals in the following contour plot. I do: [cc,hh] = contour(X,Y,Z,levels,'LineColor','k');hold on texth = clabel(cc,hh,'FontSize',8); which gets me the first contour with long labels. Then in order to cut the decimals I do: for i = 1:size(texth); textstr=get(texth(i),'String'); textnum=str2double(textstr); textstrnew=sprintf('%0.0f', textnum) ; set(texth(i),'String',textstrnew);...

How to set number of ticks along X axis in matlab?

matlab,plot,matlab-figure,figure
I'm having trouble setting the appropriate number of ticks along the Xaxis in Matlab. As you can see below, I set the number to 2 in ha.XTicksNumber=2, yet it still plots 10. nSites = 2; ha = tight_subplot(nSites,1,[.01 .01],[.1 .1],[.1 .1]); display(ha); for ii = 1:nSites; axes(ha(ii)); xData=linspace(1,100,90); plot(xData); if...

Better Method to Plot a Series of Bar Charts in Matlab

matlab,matlab-figure
I have a 4x3 bar charts which I save as figures then I combine them in one image after that in latex. The problem is that the barcharts are two small, and I'm wondering if there is any Matlab type of figure that would be better on showing my results....

Spacing between markers in scatter plot Matlab

matlab,matlab-figure
I have 6 scatter plots in one figure as shown below. A=rand(10,2); B=rand(10,2); C=rand(10,2); figure(); hold on; scatter( 1:10, A(:,1), 'r*'); scatter( 1:10, A(:,2), 'ro'); scatter( 1:10, B(:,1), 'b*'); scatter( 1:10, B(:,2), 'bo'); scatter( 1:10, C(:,1), 'g*'); scatter( 1:10, C(:,2), 'go'); I wonder if I can make some spacing between...

Algorithm equalivence from Matlab to Python

python,matlab,numpy,matplotlib,matlab-figure
I've plotted a 3-d mesh in Matlab by below little m-file: [x,n] = meshgrid(0:0.1:20, 1:1:100); mu = 0; sigma = sqrt(2)./n; f = normcdf(x,mu,sigma); mesh(x,n,f); I am going to acquire the same result by utilization of Python and its corresponding modules, by below code snippet: import numpy as np from...

How can I multiple plot in one figure at Matlab?

matlab,matlab-figure
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?...

My plotted lines aren't appearing on my output figures

matlab,image-processing,title,matlab-figure,figure
so I'm processing a bunch of images at the one time, trying to display them all as figures with a series of plotted lines on each individual image as a result of the process. With some help I fixed the figure title issue, However the plotted lines are not appearing...

finding absolute error of approximated function - matlab

matlab,matlab-figure,approximation
During an experiment i registered several points. Thereafter I approximated them with 9th order polynomial. I need to find the absolute error of the measurements and the approximated function on y axis. Any idea? *edit: y = [0.006332 0.04056 0.11813 0.1776723 0.23840 0.29827 0.358396... 0.418149 0.4786 0.478154 0.538114 0.53862 0.598954...

are there tools on linux similar to matlab .fig files and it is possible to modify the pic mannually?

python,matplotlib,plot,matlab-figure
I'm using python's matplotlib, but I can't modify the generated pictures mannually. Which is very inconvenient. Are there any tools which are similar to matlab's plot functionalities so that it is possible to modify the pic mannually? for example, I may want to modify the position of a legend. If...

How plot a messy random-size circles in MATLAB? [closed]

matlab,plot,matlab-figure
I am going to draw a figure such as below picture in the MATLAB R2014b: . This figure consists of many circles with different (random) colors and random sizes. How is it possible to plot such this figure in MATLAB R2014b?...

Multi label plot in MATLAB

matlab,matlab-figure
I want to display multiple plots for some 50 values of H. These plots coincide in a place and I want to know for which values of H it is coinciding. By legend I can differentiate only a limited number of plots with multiple color and markers. But I don't...

Moving fill background to the bottom after saving as jpg

matlab-figure
When I use fill or viscircles functions to plot circles with background to the plot, in figure it appears on the top of the plot, as it was intended, but after saving as jpg or png, the background moves to the bottom of the plot and is not visible anymore....

Save output image in matlab window to image

matlab,matlab-figure
I have a image and some contours as bellow figure. I want to save the output into image (png or jpg). The saved image only contains the image region without the matlab window. Let see my example in the figure. Could you have me implement it by matlab? This is...

Make strip of nan in a matrice matlab

matlab,image-processing,matlab-figure
I have an image size (m x n x 4) I want to make strip of 0 or NaNon it. I want the strips to be 4 pixels wide and having a space of about 30 pixels between them. That is when I display the image in RGB I have...

How to individually define line properties in plotyy() for multiple datasets plotted in right Y-axis

matlab,matlab-figure
Consider the following example from MATLAB help. x = linspace(0,10); y1 = 200*exp(-0.05*x).*sin(x); y2 = 0.8*exp(-0.5*x).*sin(10*x); y3 = 0.2*exp(-0.5*x).*sin(10*x); figure [hAx,hLine1,hLine2] = plotyy(x,y1,[x',x'],[y2',y3']); I need to individually define the colors for the two plots in the right Y axis. Also, How can we define the text color in the right...

Error in using GUIDE in Matlab

matlab,user-interface,matlab-figure,matlab-guide
This is the code for my GUI using GUIDE function varargout = testcreat(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @testcreat_OpeningFcn, ... 'gui_OutputFcn', @testcreat_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});...

How to fit the exponential function using Matlab curve fitting tool?

matlab,matlab-figure
I have a table with 2 column, c1 and c2 in Matlab. I want to use the Curve Fitting Tool to fit the exponential equation into my data. Right now I have this in my code: cftool(c1,c2); this code is going to open cftool and fit the polynomial curve! However...

Error using * Inner matrix dimensions must agree

matlab,matlab-figure,matlab-guide,telecommunication
I'm trying to calculate some functions in matlab and I'm getting this error: Error using * Inner matrix dimensions must agree. Error in set1 (line 11) x = (Ac + m)*cos(2*pi*fc*t); but I don't use any kind of matrix in my code. What is the problem about? Here is my...

Surface plot with highligheted cut

matlab,matlab-figure
I would like to plot a 3D surface using the Matlab surf function. The whole surface should be in gray scale, then I need to highlight a specific cut of the surface using a different color. I thought this code would've worked but it doesn't. Mat = randi(100); % Matrix...

How colorize Circles in a plot in MATLAB?

matlab,graphics,plot,matlab-figure
I have a MATLAB code as follows: MinVal = -1; MaxVal = 1; MaxRadius = 0.5; nCircles = 5; Dimension = 2; Circles = zeros(nCircles, Dimension); Radius = zeros(nCircles, 1); for i = 1 : nCircles Circles(i,:) = unifrnd(MinVal, MaxVal, [1, Dimension]); Radius(i) = unifrnd(0, MaxRadius, 1); end t =...

filled semicircle in Matlab

matlab,plot,circle,matlab-figure
Is there some good tip how to plot filled circle about specific point in Matlab? I've found solution for normal circle, but I dont know how fill it. I need this because I should have circle with two different colors on each half of it. Is this possible? Thank you...

How to plot on the same figure with different data and delete the old plot(s)

matlab,plot,matlab-figure
For faster operation I want to update a plot with different data in MATLAB. If I use plot3 it will open a new figure every time, which is time consuming. I cannot use hold command as I do not want earlier plots. Any suggestion?

MATLAB reset axes position copied from GUIDE

matlab,matlab-figure,matlab-guide
After copying an axes from GUIDE to a new figure, f=figure; copyobj(handles.axes1,f) I found out that the position of axes1 is not on the right place. How can I reset new axes position to the default value? This value it copied from the position in GUIDE which should not be...

getting a return value from a function in MATLAB

matlab,matlab-figure,matlab-guide,matlab-deployment,matlab-compiler
I have such a matlab function: function j = globalfun(a, xr, x) gv_0 = 0; gv_1 = 0; counter1_0 = 0; counter1_1 = 0; counter2_0 = 0; counter2_1 = 0; counter3_0 = 0; counter3_1 = 0; counter4_0 = 0; counter4_1 = 0; ............................................ ............................................ score = gv_0/gv_1; end I haven't...

visualizing 3d data volume in matlab

matlab,data-visualization,matlab-figure
I have many points in 3d (x,y,z), and for each point I have it's disparity (0-10 value), different points can have the same disparity. I want to plot this data that each point will have a color according to it's disparity. I want it to be something like this picture:...

Compression of large figures in .fig format in MATLAB

matlab,matlab-figure
My MATLAB script generates a figure from a timeseries data that, when saved, is over 200 MB in size. Is there a way to compress the figure to a lesser size in '*.fig' format? The compression has to be lossless so that I can zoom in and view the details...

matlab creating and plotting 3d points

matlab,matlab-figure
I'm trying to create a meshgrid of many many points and plotting it. It is working this way: for x=roadLeft:10:roadRight for y=0:10:50 for z=0:10:roadTop points(1,i)= x; points(2,i)= y; points(3,i)= z; i=i+1; end end end plot3(points(1,:),points(2,:),points(3,:), '*b') but this is ugly and I'm sure there's a way to do it with...

Keeping the same scale across different heatmaps

matlab,matlab-figure
I plot heatmaps using subsets of a dataset. I wish to compare different heatmaps. How can I keep the scale of the datasets the same? Basic Code Used: num_points = 100; ke_pts = linspace(min(ke(filter)),max(ke(filter)),num_points); ks_pts = linspace(min(ks(filter)),max(ks(filter)),num_points); Pest = gridfit(ke(filter), ks(filter), S.totForce(filter), ke_pts, ks_pts); imagesc(ke, ks, Pest) axis xy h...

parametric integration and numeric plotting of a 2D function

matlab,matlab-figure
I am going to devise a 2D function as a probability density function, is which a function of two variables, i.e. f = f(x,n). Then, as the target is plotting the probability variation, the integration in related to parameter x should be taken into account. The t parameter is the...

Setting multiple line colors in matlab figures simultaneously to different values

matlab,graphics,plot,matlab-figure,handle
I have a figure in MATLAB with some lines, that get automatically assigned to various colors, and I want to set the same color sequence to other figure objects. For example: x = 0:10; y = 0:0.5:5; h = plot(x,y+1, x,y+2), hold on g = plot(x,y-1, x,y-2) % want to...

Data Is Missing On Figure Matlab

matlab,plot,matlab-figure,ode,differential-equations
I have a question - why is the part of data missing on the figure? Please help me, I am stuck and have no idea =( Here is the code for ode: function xDot = parallelDegreesW4(t,x,~,w_af,g_af,gcurr) xDot = [x(2); ... %//= theta' sin(x(1)) * cos(x(1)) * ((x(4))^2) + ... (w_af^2)...

Graph in a square in MATLAB

matlab,matrix,matlab-figure
I have a matrix with 7 lines, which I upload automatically and generate a graph. I can't figure out, how I can represent it exactly in a square. My graph made by the matrix looks like this: This is the code which displays the matrix from my file: reverse_matrix =...

Matplotlib: move Origin to upper left corner

python,matplotlib,matlab-figure
In Matlab, the plot is to be made such that origin is on top-left corner, x-axis is positive south to the origin, y-axis is positive east to the origin; x-axis is numbered on the left margin and y-axis is labelled on the top margin. figure(); set(gca,'YAxisLocation','Right','YDir','reverse') axis([0 10 0 10]);...

Plotting arrays from a cell list of strings

matlab,matlab-figure
Suppose I have different rows loaded from a .mat file (using load filename.mat) containing float numbers following the same naming convention, e.g: file_3try = [ 2.4, 5.2, 7.8 ] file_4try = [ 8.7, 2.5, 4,2 ] file_5try = [ 11.2, 9.11 ] to plot all of these in one plot...

Axis scales in the heatmap

matlab,matlab-figure
Pest = gridfit(ke, ks, S.totDis, ke_pts, ks_pts); imagesc(Pest) colorbar; xlabel('k_e'); ylabel('k_s'); I wish that the scale of the axis be the values of data instead of the data point indexes. This might be naive. I am new to matlab, please help. Edit: I wish the y-axis to be increasing instead...

Set data tips programmatically?

matlab,plot,matlab-figure
I need to be able to set data tips programmatically from a list of array of x axis values. For example, I create a figure and plot my data. figure;plot(t1,[filter(b,a,Gyro(:,2)),filter(b,a,Gyro(:,4))]) I have a set of timestamp values from t1 variable (time) (e.g. [0.450, 0.854, 1.2343....]) where I want to place...

How to add labels on each line and add 2nd y-axes to the right side of the 'loglog' plot?

matlab,plot,matlab-figure,iso,loglog
Recently I am trying to implement the ISO classification for the roadway assessment. Please refer to the paper The use of vehicle acceleration measurements to estimate road roughness. But I bumped into some questions about plotting the ISO classification graph. The code is shown as follows: %% generate ISO Clasification...

Matlab define callback function for mouse click on a biograph

matlab,matlab-figure,matlab-guide
all! This is my first question on stackoverflow! In matlab, I create a biograph and visualize it. cm = [0 1 1 0 0;1 0 0 1 1;1 0 0 0 0;0 0 0 0 1;1 0 1 0 0]; bg1 = biograph(cm); view(bg1) Now I want to define callback...

frequency spectrum of sinc function in matlab shows me nothing

matlab,fft,matlab-figure
since i don't have sinc function in my MATLAB, I implemented that function as shown below %% time specificactions: Fs=10000; dt=1/Fs; t=(-0.1:dt:0.1-dt)'; N=size(t,1); %message signal mt=(sin(pi*100*t))./(pi*100*t); %% frequency specifications dF=Fs/N; f=-Fs/2:dF:Fs/2-dF; M=fftshift(fft(mt)); plot(f,abs(M)/N); but the figure shows me nothing but blank, so i looked up the variable table and it...

How to set x and y values when using bar3 in Matlab?

matlab,matlab-figure
Quick version How can I control the x- and y-values for a 3-d bar plot in Matlab? Details Say we have an 10 x 20 data matrix and we plot it using bar3, and we want to set the x- and y-values. For instance: foodat = rand(10,20); xVals = [5:14];...

How can I change uipanel dimensions by using user input?

matlab,matlab-figure
I'm trying to change panel and axes width and height values by using user input. These values will represent a photograph's resolution. For example, if a user inputs 512*512, the uipanel and Axes' width and height will change to 512 and the user will work on this workspace. What I...

how to convert contour plot from mathematica to matlab

matlab,wolfram-mathematica,matlab-figure,contour
I am trying to draw a contour for an equation which I got from Mathematica. I was able to draw this contour easily in mathematica but not on matlab. Kindly suggest. b=linspace(0.0005,0.0010,100); c=linspace(0.64,0.7,100); z=(-136*power(2.718281828459045,power(88682,c)*b)*(1 - 1/power(2.718281828459045,1*power(88682,c)*b)))/(-1+ power(2.718281828459045,power(88682,c)*b)) - 1*(power(3,c) + power(33,c) + power(146,c) + power(227,c) + power(342,c) + power(351,c) +...

Saving Figure as High Resolution or Lossless Image that can be Zoomed in without Pixelation

matlab,matlab-figure
I have a big plot in MATLAB (4095 points total) and I want to export this figure as a high res image which can be zoomed in just like the original figure can be zoomed in. Below I attached two images, one is full size plot and the second one...

Labels in yyplot

matlab,plot,matlab-figure
My problem is that the figure that I'm creating gets "two types" of x-axe labels. One is the ones that I have asked for, the other is a number, its displays it every 2. Actually, labels and numbers are overlap. I'm new to the forum, hence it does not allow...

Defining legend for pcolor plots in MATLAB

matlab,plot,matlab-figure
Consider the example shown in the following figure, The first subplot shows 3-axis accelerometer data(not relevant, just an example!) and the second plot shows the corresponding computed body postures in a pcolor plot. The problem here is there are 6 possible postures, but not all the postures will be covered...

Add a common legend for several barcharts Matlab

matlab,matlab-figure
I have a 5x3 barcharts all of them have the same legend. I'm wondering if there is a way so that I can combine them all in one figure and have only one big legend as a row in the end instead of putting 15 tiny little legends in each...

How do I make figure full screen in Matlab?

matlab,fullscreen,matlab-figure
please, this question is not that simple, you may think it is already answered but it is not the case. I know how to make a next figure in full screen : figure('units','normalized','outerposition',[0 0 1 1]); But what I want is not the next figure . But figure Number 3...