﻿ oipapio

### properties - Matlab scatterhist plots - display only one histogram

In Matlab, I want to plot data as a scatter plot, and display the marginal histogram at the side of one axis only.I came across the scatterhist() function, which does exactly what I was looking for, except it always displays marginal histograms for both X and Y axes. Surely there's a way to remove one, but can't find the options.My code as an example:h = scatterhist(xrange, ydata, ... 'Kernel','on', 'Location', 'SouthEast', ... 'Direction','out', 'Marker','.');An image of my problem is below (I am using the kernel density line instead of ...Read more

### matlab - Calculate vertex normals for parametrically morphed sphere

I want to morph sphere, using the following equation:R=1+k*(cos(4*elev)+sin(4*az)),Spherical coordinates elev and az are transferred as gl_Vertex. The problem is to calculate normals for such morphing. I may calculate them, just shifting az and elev a bit, the obtain 2 more "virtual" vertices and use standard approach with cross-product, but it looks rather ugly and expensive approach.Is their are any way to calculate normals also parametrically for such kind of morphing? UPDATE:Thanks to @meowgoesthedog, but I still have problems. My implement...Read more

### user interface - MATLAB Edit Focus and Cursor Placement

I am using the uicontrol command to have focus on my edit object. After this command, the string inside the uicontrol is selected. How can I place the cursor after the last character ?Here is my code.H = figure;E1 = uicontrol( 'Parent', H, 'Style', 'Edit', 'String', 'ABC', 'Units', 'Normalized', 'Position', [0.1,0,0.1,0.1] );T1 = uicontrol( 'Parent', H, 'Style', 'Text', 'String', 'ABC', 'Units', 'Normalized', 'Position', [0.2,0,0.1,0.1] );uicontrol( E1 )...Read more

### user interface - Matlab - AppDesigner: Interrupt a loop with GUI

I have created a GUI which computes a trajectory based on an external .m file.When the user press the 'Calculate' button the external .m function file gets called via the callback function of the button:% calculateBtn button pushed function function calculate(app) numSteps = app.stepSlider.Value; app.omega = app.omegaSpin.Value; app.phid = app.phi.Value; app.x0 = app.x0Spin.Value; app.y0 = app.y0Spin.Value; app.u0 = app.u0Spin.Value; app.v0 = app.v0Spin.Value; set(app.calculateBtn, 'Ena...Read more

### image processing - How can I detect the dimensions of an object under an angle in this picture in MATLAB?

I have this image of a battery:I would like to determine the dimensions of the battery (in pixels).The problem I have is that the battery is rotated by an unknown angle.How can I detect the dimensions of this rotated battery? I was thinking of these algorithmic steps:First, I would have to convert this image to a black and white image (thresholding). After that, I would have to find a center point and draw a rectangle in the white pixels. Then, I have to turn the rectangle 360 degrees and locate the position of the rectangle (and so the d...Read more

### Expanding a 2D Matrix in Matlab with Interpolation

Let's say I have a 4 pixel by 4 pixel image with values between 0 and 255 and I want to expand it to an 8-by-8 image, interpolating where necessary. I know how to interpolate a vector this way with interp1:interp1(linspace(0,1,numel(vector)), vector, linspace(0,1,newSize))But I'm unclear how to use interp2 to do the same thing for a matrix.EDIT: Would it be the same if I were to create a meshgrid after using linspace for each dimension?EDIT2: Yep, that worked. It's the same, but with a meshgrid....Read more

### Matlab import of .dm3 image files broken after recent GMS update

I'm trying to read in dm3 files with Sigworth's Matlab script (ReadDMFile.m to be found here)The script attempts to extract these tags:'ImageList 2 ImageData Calibrations Dimension 1 Scale''ImageList 2 ImageData Calibrations Dimension 1 Units''ImageList 2 ImageData Dimensions 1''ImageList 2 ImageData Dimensions 2''ImageList 2 ImageData Dimensions 3''ImageList 2 ImageData Data'But the cell ('output') that should contain the results, comes up empty. This same script has no problems reading dm3 files that were recorded by the same hardware and sav...Read more

### matlab - Import table with readtable if row is shifted in .txt file

I have a table that looks like thisx x x x x x x xy y y y y yy yz z z z z z z z I want to import it using readtable such that all the x are in one row, all the y in the next row, etc. In other words, in the .txt file the last two contents that are supposed to be in one line are shifted into the next. I think I need to change something in DelimitedTextImportOptions but I cannot figure out what exactly. Would be glad if someone could help me with this, thank you very much in advance!...Read more

### loops - Sequential import of datafiles according to rule in Matlab

I have a list of .txt datafiles to import. Suppose they are called like thatfile100data.txt file101data.txt ... file109data.txt I want to import them all using readtable.I tried using the for to specify a vector a = [0:9] through which matlab could loop the readtable command but I cannot make it work.for a = [0:9] T_a_ = readtable('file10_a_data.txt') endI know I cannot just put _a_ where I want the vector to loop through, so my question is how can I actually do it?Thank you in advance!...Read more

### Unable to import data in matlab from a unlabelled file format

I have downloaded noisy MNIST dataset from data link but the file downloaded is of unknown file format its written in the description that the available file is in mat format so I renamed the uncompressed file to .mat format. but when I try to upload it to matlab it shows the folowing error Unable to read MAT-file F:\ data\mnist-with-motion-blur\mnist-with-motion-blur.mat. Not a binary MAT-file. Try load -ASCII to read as text.I have also used mnist helper function but it didn;t help.helper mnist...Read more

### loops - Matlab Import and combine multiple dat files

I am trying to import multiple .dat files, process them and combine into a single matrix. In this case, I need to divide each cell by its time (i.e. normalizing factor).This example is for 2 dat files, I managed to do it, but I have a lot of files, up to data100raw, and I hope to have a loop to process everything in one go, while allowing me to set a different normalizing factor for each file.data1raw = importdata('2015-04-19004-190-31.04-20140819-5sample transport-PL spectra 10s-0mm.dat')data2raw = importdata('2015-04-19004-190-31.04-20140819-...Read more

### extracting numeric data from text in data files in Matlab

I have a .txt data file which has a few rows of text comments in the beginning, followed by the columns of actual data. It looks something like this:lens (mm): 150Power (uW): 24.4Inner circle: 56x56Outer Square: 256x320remarks: this run looks good 2.450000E+1 6.802972E+7 1.086084E+6 1.055582E-5 1.012060E+0 1.036552E+02.400000E+1 6.866599E+7 1.088730E+6 1.055617E-5 1.021491E+0 1.039043E+02.350000E+1 6.858724E+7 1.086425E+6 1.055993E-5 1.019957E+0 1.036474E+02.300000E+1 6.848760E+7 1.084434E+6 1.056495E-5 1.017992E+0 1.034084E+0By usin...Read more

### matlab - extra lines in command window output

I am very new to MATLAB and i am currently trying to learn how to import files in matlab and work on it. I am importing a "*.dat" file which contains a single column of floating point numbers[they are just filter coefficients I got from a c++ code] into an array in MATLAB. When I am displaying the output in command window the first line is always " 1.0e-03 * " followed by the contents of my file. I want to know what it means? When I check my workspace the array connects the correct number of inputs. My sample code and first few lines of output ...Read more

### Open a text file, scan it and plot it in MATLAB

I am trying to open a text file in MATLAB and plot it in a graph. The following is my code:%% Get the data [filename, pathname] = uigetfile('*txt', 'Pick text file');x=filename(:,1);y=filename(:,2);plot(x,y);But each time I run it, I get following error:Error using plotInvalid first data argument.Error in readtxtfile (line 5)plot(x,y); The text file that I imported has 2 rows. I am planning to plot the first row with the second say plot (row 1, row 2) in MATLAB....Read more

### MATLAB: To import txt file and to remove every header after n-row then keeping the first column only

i have txt file looking like below which i need to import to Matlab and keeping only values of 'p'. However 'p' in every 'time' is stored in different column in matlab workspace. Size of 'p'for each 'Time' would be '8x1'. Thank you for any help. ASCII VARIABLESNB =7Time0IBpTS1S20394.966343.150.10.91394.966343.150.10.92394.966343.150.10.93373.745343.150.10.94373.745343.150.10.95373.745343.150.10.96363.134343.150.10.97363.134343.150.10.9Time0.01IBpTS1S20394.966343.150.10.91394.966343.150.10.92394.966343.150.10.93373.745343.150.10.94373.745343.150...Read more