In a very big image dataset, we have some corrupted images as following images. These images can be viewed without any problem, but human eyes can see some corrupted areas in gray color. How can I detect these corrupted images？ Actually I have written a script in Matlab for detecting....

I have two vectors, one of them stores the width dimension of a set of images and another one the height of these set of images. I want to use these values as two dimensional vectors [width height] and store them in a matrix. The first line, for instance, keeps...

How can I change "Validation Checks" value from 6 to higher or lower values using code? I have following code: % Create a Pattern Recognition Network hiddenLayerSize = ns; net = patternnet(hiddenLayerSize); net.divideParam.trainRatio = trRa/100; net.divideParam.valRatio = vaRa/100; net.divideParam.testRatio = teRa/100; % Train the Network [net,tr] = train(net,inputs,targets); % Test...

In Matlab functions can be started at events,but occasionally, like with the resize function, the events are called in rapid order and the function is called many times in succession, which can cause weird behavior and lag. Is there a way to have it listen for the event but only...

I'm trying to equate each element to an array which correspond to cell element. To explain it more precisely, e.g A = {[1 1 1], [0 0 0 0 0], [1 1],[0 0 0 0 0]}; B = [0 1 0 0]; So the thing I want is : A=...

How could I input directly a matrix into a cell that has been loaded from an address? For example, if Response is defined as a cell: Response(1,1)={load (['sourceETA/Tn',num2str(period*10),'/ETdisp.txt'])}; But the above code doesn't work! How do I do?!...

I have a very simple question, but I didn't figure out how to solve this.I have the function definition below: function model = oasis(data, class_labels, parms) % model = oasis(data, class_labels, parms) % % Code version 1.3 May 2011 Fixed random seed setting % Code version 1.2 May 2011 added...

I want to store mean_2....mean_8, std_2....std_8, and coVariance as separate columns in a file. Help Please? This Code calculates IntervalFeatures of Erp signal with 256 time frames and plots them Datapoints are store in A ___________HowTheCodeWorks________________________________________________ each 1x4 sliding sub-matrix is made a column for eg:- if A is...

I have a [32678 x 10] matrix (w2c) and I want to copy 24700 rows of it to another matrix(out). I have the index of the rows to be copied in a vector(index). For doing this in matlab I do: out = w2c(index_im,:); It takes approximately 0.002622 seconds. In OpenCV:...

I need to create a structure in MATLAB which is like this: under the main struct there are 3 sub-structures: Left, Right, Center. Under Left and Right there are 18 sub-structures each (A,B,C,D,E,...), and under Center there are 5 sub-structures. Under each of the 18 and 5 sub-structures I have...

Hi I have data in MATLAB like this: F = 1.0000 1.0000 2.0000 1.0000 3.0000 1.0000 3.1416 9.0000 4.0000 1.0000 5.0000 1.0000 6.0000 1.0000 6.2832 9.0000 7.0000 1.0000 8.0000 1.0000 9.0000 1.0000 9.4248 9.0000 10.0000 1.0000 I am looking for a way to sum the data in specific intervals. Example...

I have some random signal (for example sin signal) with the time scale. t=0:0.1:2*pi y=sin(t) plot(t,y) Now I want to draw this signal on this circle. So the time vector actually becomes an envelope of the circle. Envelope of the circle represents "y = 0" in cartesian coordinate system. Here...

I'm quite new to using MATLAB, and am still trying to understand how to make this particular function. I understand the formula for performing this on paper, but I'm having trouble translating it into the required MATLAB syntax. How would a function be written such that it takes an array...

I have a string "FDFACCFFFBDCGGHBBCFGE" . Could anyone help me to generate a new string with the same order but no element inside repeated twice. Thanks ! The expected output should be like this : "FDACBGHE"...

I have a data matrix X of size p*n where p=10 and n=30. Assume the covariance matrix S = XX'/n and its eigenvalues by the vector l. I want to compute this formula in MATLAB: I began by writing the code but I don't know how to write the sum...

I am doing some bone segmentation whereas the result of this segmentation is points placed in a circular pattern around this bone. However as it is taken using a qCT scan, there is quite a lot noise (from e.g. flesh) on the points that i have. So the overall problem...

I have a binary matrix containing several binary objects and I want to bridge between them. Actually I have the following picture: And the result has to be like this: Is there any function or a shortcut way, other than loops, for this problem?...

I would like to plot series of known coordinates as lines onto a figure of known width and height. Then import a .avi movie of the same height and width, and then combine these two so that the lines overlay the video. I've been looking around google and stackoverflow, but...

I am trying to merge two matrices that share same values in multiple columns. The following matrices should exemplify my problem and provide a MWE. However, my data is very long size(500000, 4), therefore I am searching an efficient way to merge them. The data consists of option data where...

This is my one dimensional array A. containing 10 numbers A = [-8.92100000000000 10.6100000000000 1.33300000000000 ... -2.57400000000000 -4.52700000000000 9.63300000000000 ... 4.26200000000000 16.9580000000000 8.16900000000000 4.75100000000000]; I want the loop to go through like this; (calculating mean interval wise) - Interval length of 2,4,8 (a(1)+a(2))/2 - value stored in one block of...

I have a 1*3000 double matrix. I am doing some calculation and I need to calculate sum of n-1 columns in each step. For example, if I have this matrix: A = [1 2 3 4 5 6] The summation I'm looking for should be like this: B = [0...

I have a variable 'b'. Inside of b, I have 27X1 cell. In every cell there is some characters for example in 1x1 there is asdf, in 2x1 there is dfgh it's going on like this. I want that matlab creates mat files which names are asdf, dfgh and assign...

I have a symmetric matrix S(n*n) where approximately 70% of the data are 0. Symmetric matrix I want to convert the symmetric matrix into a sparse matrix with t rows. What would be the time complexity of generating a sparse matrix from the original symmetric matrix? Is it O(n^2), because...

I have the following matrix A in Matlab of dimension (m*d)x2 A=[1 1; 3 2; 8 3; ----- 9 1; 2 2; 5 3; ----- 6 1; 1 2; 4 3; ----- 8 1; 1 2; 5 3]; Hence m=max(A(:,2))=3 and d=4 is the number of submatrices in A of...

I want to generate a random binary sequence with a ratio of 50%, that is, the same amounts of 0s and 1s. This is what I have so far: length_sequence = 1000; ratio = 0.5; A = logical(randi([0 1],length_sequence,1)); The only problem is that I dont know how to set...

I am working on a simple System Object in Matlab/Simulink. It looks like this : classdef realtime_header_detectorSO < matlab.System & matlab.system.mixin.Propagates % correlateHeader % % This template includes the minimum set of functions required % to define a System object with discrete state. properties Header %nrOfBitsInPreviousStep=0; s=100; d=zeros(1,s); end properties...

Is there any function that can calculate cumulative maximum for a double matrix? I have a 1*3000 matrix and I need to calculate the cumulative maximum. For example if the matrix is: A = [8 3 6 7 9 10 6 2 2 3] The cumulative maximum array will be:...

Trying to change the optimopts properties of the factoran function, namely, TolX and TolFun in Matlab but apparently the values are still remaining as the default: optionsFactoran = statset('TolX',1e-4,'TolFun',1e-4) and then using the factor analysis function: [lambda,psi,T,stats,F] = factoran(MyMatrix,10,'optimopts',optionsFactoran); as can be seen here, the values are still the default:...

my matlab version is 2012a. when I use fitcknn,has this error: Undefined function 'fitcknn' for input arguments of type 'cell'. how to calculate probability for each class for predicate with knn without fitcknn? after use this code, I want to calculate prob_estimates for each neighbors: knn = ClassificationKNN.fit(trainsample, trainlabel,'NumNeighbors',7); y...

I write numeric data to MS Access tables. All the tables have the same numeric fields format (ie 'real simple', 'standard', 'auto'). I push numbers via Matlab in the tables and MS Access rounds numbers to the 1rst decimal and i can't modify it. Does someone know ? Screenshots there...

I have 8 traveling consultants that need to visit 155 groups across the continental united states. Is there a way to find the optimal 8 regions based of drive time using k-means clustering? I see there are some methods implemented already for other data sets, but they are not based...

I have calculated 3 histograms for an rgb image using imhist function in Matlab, one for each channel. I want to plot these histograms on the same graph, where for instance, the histogram for the first (red) channel stretches on the x axis from 0 to 255, the histogram for...

I'm trying to remove the rows which has duplicates in sequence. I have only 2 possible values which are 0 and 1. I have nXm which n shows possible number of bits and m is not important for my question. My goal is to find an matrix which is nX(m-a)....

Good day, I have the following code which has given me problems for a day already. I have debugged it, and it works fine until trying to free the memory. The free() function should be called at the end of the execution automatically, so I commented the mxFree() code out,...

I want to display three figures in a figure window. Assuming that I divide 2x2 regions. subplot(2,2,1) ---------+----------- | R1 | R2 | ---------+----------- | R3 | R4 | ---------+----------- I want to show a figure merging R1 and R3 ant other two in R2 and R4 I can display...

I'm writing a piece of code where I can define a number of matrices that will be generated and then a loop generates them. The piece where I'm struggling is on the "naming" of the matrices, since I want to name as follows: matrix1; matrix2; etc. The code below is...

I'm having a weird problem in training an SVM with an RBF kernel in Matlab. The issue is that, when doing a grid search, using 10-fold cross-validation, for the C and Sigma values I always get AUC values equal to approximately .50 (varying between .48 and .54 depending) -- I...

I have a little experience with Matlab, but am new to the mex environment. What I am trying to do is to save some values I compute to a txt file in my C routine. For the sake of simplicity I am using the example arrayProduct.c from MathWork's Create C...

How can I create a vector x in Matlab that has values between 0.8 and 1.2, randomly sampled from a: 1. Uniform 2. Normal distribution? There are a lot of functions dealing with distributions, but I'm having trouble using them properly....

I am trying to read all the images in the folder in MATLAB using this code flst=dir(str_Expfold); But it shows me output like this. which is not the sequence as i want. Can anyone please tell me how can i read all of them in sequence? for giving downmark, please...

So, I want to be able to look at (read: copy) MATLAB's NonLinearModel method of printing the regression results to the screen such as this. Nonlinear regression model: y ~ (alpha1 - alpha2*t^0.5) Estimated Coefficients: Estimate SE tStat pValue alpha1 1.0253 0.0082253 124.66 4.8823e-24 alpha2 0.0061783 0.00073277 8.4314 4.4834e-07 Number...

I am trying to create a GUI using GUIDE where it allows the user to pick one of two pushbuttons. The strings in the pushbuttons will vary each time (I haven't automated this yet), but when any of the pushbuttons is pushed, I'd like the GUI to put out the...

I'm currently using a MATLAB to work and I need some help: I need to convert my output data (variable: units) be a double instead of a cell because I must perform a sum: units = inputdlg(question,title); sum = units + i; I've tried this code also but didn't solve...

I have a script which aims to detect of gaps between genes along chromosomes, the coordinates of these gaps and assign a category to the gap. It takes an input file in this format: Chr start finish dir chrI 335 649 + chrI 538 792 + chrI 1807 2169 -...

I am try to plot 16 bars, 8 of these belong to one group. I want to give this group the red color, the other 8 belong to another group which is given the blue color. I would like to arrange the bar in pairs, each pair containing one from...

Code tfr = abs ( tfr ); [row_size, column_size] = size(tfr); tfr = tfr(1:round(row_size/2), 1:row_size); surf(tfr); view(2); I get in R2014b of OSX 10.10.3 Yosemite but rotating around shows that the cells should not be black Why is the output black? I wonder if this is a hardware problem or...

i have a question regarding legend for movies. This is my code: fig = figure(); for i = 1: 70000 plot(signal1) hold on; plot([i,i],[-5,5]) plot(signal2,'r') hold off; title('\fontsize{14} my data'); legend('signal1','signal2'); axis tight; f(i) = getframe(fig); end The legend shows the same colors for the first two things I plot....

I'm trying to plot a line graph and a bar graph on the same y-axis: figure; plotyy(Pert, Rfootvel(:,i+1), Pert, 0,'bar','plot'); hold(ax(1), 'on'); legend('Pert 1-8', 'Base'); ylim(ax(2), [0 1]); title(['The avg pert velocity of the first step vs the avg base velocity, PP' num2str(j)]); Unfortunately, setting the second y-axis limit like...

sorry if it already has a answer..i tried other links but it didn't understand i have 2 1*63 array .landa and v. each of their members are syms. and each v member is a function of all landa members.i have already calculated v members and they are all symbolic equations...

I managed to create a java package from a Matlab function (for image processing) using deploytool. I tested it in Eclipse and it runs perfectly. The problem is that I want to use this Matlab function for an Android Studio project and I can´t find any way to make it...

This is my implementation of CostFunctionJ: function J = CostFunctionJ(X,y,theta) m = size(X,1); predictions = X*theta; sqrErrors =(predictions - y).^2; J = 1/(2*m)* sum(sqrErrors); But when I try to enter the command in MATLAB as: >> X = [1 1; 1 2; 1 3]; >> y = [1; 2; 3];...

Let's say I have a time series represented in a numpy array, where every 3 seconds, I get a data point. It looks something like this (but with many more data points): z = np.array([1, 2, 1, 2.2, 3, 4.4, 1, 1.2, 2, 3, 2.1, 1.2, 5, 0.5]) I want...

Hello lovely community, i am quite new here, but still hope someone can help me out. I just worked a bit with Matlab in the past and want to do a new project. Earlier I just stored all in one Matlab file and didn't had the need to use classes....

Trying to figure out if I have access to function object programming techniques for use in our Matlab scripts. This would be analogous to .NET's Func type, or Python's function objects. Does Matlab give functions first class object status?

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...

I would like to add the elements to the array using their index. array_in = [1 5 6 8 9]; index = [2 4]; newElements = [25 67]; index = index + (0:length(index)-1); expected output: array_out = [1 25 5 6 67 8 9]; 1.using for loop: tmp = array_in;...

Is there a shortcut to comment multiple lines in matlab. If there isn't can I create one?

Is it possible to add statements in between the codes. For example: If I have a code like this, r(:,1) = a(:,1) - a(:,2); Then can I write it as, r(:,1) = a(:,1)("this is a constant") - a(:,2)("this is a variable"); ...

I'm having problems multiplying specific values within my multidimensional matrix by a scalar. My matrix has the following dimension: size(comDatabe) = 5 10 3 397 10 The third dimension is an x-y-z coordinate frame. Something went wrong and now my y-axis is defined upside down for one subject (#8 out...

How can I solve , where and and in the least squares sense in matlab? So I'd like to have the minimizing as output....

I have a matrix looks like: 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 2 0 0 0 0 0 1 0 1 0 0 0 1 0 4 0 0 0 0 0 3 0 0 6 0 0 4...

I am using the below mentioned code to get the file names of images according to their id's from images_1 text file as strings and use them to read the images from their directory image_count=1; for image_count=1:6 file=fopen('D:\Academics\New folder\CUB_200_2011\images_1.txt','r'); C = textscan(file, '%s'); original_image=imread('D:\Academics\New folder\CUB_200_2011\images\%s','C{1}{2*(image_count)}'); imshow(original_image) end I am able...

I have matrix A and matrix B. Matrix A is 100*3. Matrix B is 10*3. I need to insert one row from matrix B each time in a sequence into matrix A after every 10th row. The result would be Matrix A with 110*3. How can I do this in...

I am trying to calculate portfolio cVaR (conditional value at risk) levels from my simulated data for various portfolios. I am able to do that for one single portfolio using the following code: % Without a for-loop for series 1 test2 = test(:,1) VaR_Calib_EVT = 100 * quantile(test2, VarLevel_Calib); help1...

A text file could be loaded as below: load sourceETA/Record1/result1.txt How can I use a variable in address of loading? For example (n is a variable): [load 'sourceETA/Record1/result',num2str(n),'.txt'] But the above code doesn't work! How do I do?...

I cannot get Matlab to plot a a second time series to specific points along the x axis. My data are two time series. Time series A is a 5 X 1 and time series B is a 7 X 1. I need A to plot on xticklabels 1-5. Then,...

Could someone explain the logic of this program. I dont understand why the y=y/max(y) and, interp = (0.5-y(i-1)) / (y(i)-y(i-1)); tlead = x(i-1) + interp*(x(i)-x(i-1)); The script: function width = fwhm(x,y) y = y / max(y); N = length(y); MicroscopeMag=10; PixelWidth=7.8; % Pixel Pitch is 7.8 Microns. %------- find index...

I use matlab code to read several files and write output in the following way: n=202; for idx = 0:n infilename = sprintf('pt%d.txt',idx); outname = sprintf('out%d.txt',idx); Now if some arbitrary data files are missing e.g. pt20.txt, pt50.txt ,etc then the code is terminated. I would like to modify the code...

I have 20 column vectors in the workspace and I'd like them all to be contained within a cell array. They're all labelled data1, data2, data3,...data20. Is there a faster way to do this than: cell = {data1, data2, data3, data4, data5, data6, ...} all the way up to data20?...

What is the ellipsis for in this Matlab statement? frame = insertObjectAnnotation(frame, 'rectangle', ... bboxes, labels); ...I could not find in their online doc....

I have some problems when it comes to defining a callback function and using handles. h1 = uicontrol('style','pushbutton','units','pixels',... 'position',[40,5,70,20],'string','test',... 'callback',@h1_call); I create a button with the code above and want to plot some information stored in the handles if I push on this button. function h1_call(handles) axes(handles.ax1) plot(handles.x,handles.y); sadly this...

I have a labeled matrix containing two objects. How can I thicken an object to a curve? Actually I have the following image: and I want this: Each pixel of the resulting curve is the median of each column. But if you have another idea, it is acceptable, because I...

I have a data set (D) of (nxd) where n=number of rows and d= number of dimensions, I create a similarity matrix (S)(nxn) by comparing each row of the data set (D) and then convert it into a sparse matrix (tx3) where t is the number of non-zero elements of...

I'm trying to add legends the plot when it adds a curve. I can't see whats wrong with my code, can someone please help? I'm using matlab r2015a on ubuntu. x=1:5; v=1:5; plot(x,v) [~,~,plots,str] = legend('1'); hold on for i=4:10 pl=plot(x,v*i); [~,~,plots,str]=legend([plots;pl],str,num2str(i)) end when i run it i get: plots...

I have come into a problem recently when trying to rotate 3D objects. I am building a GUI and I have a separate figure where an object is plotted. In the figure, I allow the user to use MATLAB's built-in rotate button to move the object around. However, I am...

With the use of Curve Fitting toolbox I'm fitting to 11 data points a curve described by a custom equation. As a result I get something like this: I want to save 1D vector represented bye the red line on the plot above into a matlab variable. I try to...

I have a 4D matrix with dimensions 7x4x24x10 (Lets call it main_mat). I want to get a matrix of size 7x4x24 (rand_mat) so that each element of this (rand_mat) matrix is actually a uniformly random draw from the main matrix (main_mat). I am sorry if I have not put the...

I have a data set of n = 1000 realizations of a random variable X and is univariate -- X = {x1, x2,...,xn}. Data is generated by varying a parameter on which the random variable depends. For example, let the r.v be Area of a circle. So, by varying the...

I need to perform a double integration using experimental data, but my integration limits are the same for each integral, in this case, the time. Mathematically I need to calculate: E [ a0+ ∫0T a(t)dt ] = a + limTx → ∞ (1/T) ∫0T ∫0t a dt dT After some...

I have a semilogarithmic plot which works so far with semilogx. Now I would like to change the tick labels. Now it says 10^8 10^9 ... 10^13, but I would like to see 1e8, 1e9, ... 1e13 on the x-axis. How can I change that? Cheers Manuel...

I have the following code: syms z Gc=1.582*(1-0.3679*z^-1)/(1+.418*z^-1); Ghp=.3679*(z^-1)*(1+.718*z^-1)/((1-z^-1)*(1-.3679*z^-1)); T=(Gc*Ghp)/(1+Gc*Ghp); clipboard('copy', latex(simplifyFraction(T))); Which results in following for T: How can I normalise coefficients? I.e. I want the z2 in denominator and z in numerator to have the coefficient of 1. Is there any function in Matlab to do so?...

I need to save a set of pre-processing images in matlab, resulting in grayscale images. The problem is the fact that these pre-processed images have pixel values higher than 255. If I save them with imwrite() as, for instance, .PNG files, does matlab normalize the values to be in [0,255]...

I have a bunch of angle data ranging from 0 to 180 degrees, along with an equal amount of distances ranging from 0 to 15 meters. I'm looking for a way to get a semi circle (like the top half of a rose plot) where for each data point I...

I have an image which I want to divide into overlapping blocks. I have set the box to be of size 8 rows and 8 columns, and the overlapping factor to be 4 rows/columns. This is what I have written to solve this: img = imread('a03-017-05.png'); overlap = 4 count...

I try to read data from the COM3 port. I'm using : in = fscanf(s); if(in == 'A') fclose(s); break; end The problem is, when no data is send to the com3 port, the fscanf line will wait for a certain time and than give a timeout. Is there a...

The follow plot shows my question: I would like to add a line between the points of 1e-1 and 1e-2. So I thought just (1e-1+1e-2)/2. But for a log scale that is not "midway". How can I calculate the "visual" midway value between these, or any two points in this...

This is my one dimensional array A, containing 10 numbers: A = [-8.92100000000000 10.6100000000000 1.33300000000000 ... -2.57400000000000 -4.52700000000000 9.63300000000000 ... 4.26200000000000 16.9580000000000 8.16900000000000 4.75100000000000]; I want the loop to go through like this; (calculating mean interval wise) - Interval length of 2,4,8 (a(1)+a(2))/2 - value stored in one block of...

I am trying to display a table with two columns and 86 rows. Instead of outputting the rows, the size is stated. Is there a way to change this? I am new to MATLAB and am coming from a background in C/C++ so I may just be approaching this all...

I have a column vector of values between 0 and 180. I'm looking for a way to extract all the values as columns between 0 and 5, then all the values between 5 and 10 and so on up to 180, and then save all these into a cell array....

i have a bar graph having three bars as follows x=[0.22,0.34,0.42] bar(x,0.1,'stacked') somenames={'IND Relation' ; 'DIS Relation' ; 'EQ Relation'} set(gca,'xticklabel',somenames) ylabel('F1') all the three bars are in blue color but i want to represent IND Relation with Brown color, DIS Relation with green color and EQ Relation with blue...

I'm trying to have 3 lines come out from the centre of the graph at x = 0, going to the coordinates marked by the black dots. I got the black dots using scatter(X,Y); but can't find a way to have lines emanating from the origin to these dots....

I am trying to code a system of ODE's shown below. As seen, the second ODE completely depends on the value of the first ODE. How can I code the second ode? I am using ode45....

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...

I have two matrices of the same size. First matrix: weights 800 x 1250 Second matrix: country_code 800 x 1250 Each column is an observation. What I would like to do is sum each column in the weights matrix based on the country_code. An example below might explain it better...

Is there an alternative way to call a C++ class using MATLAB, and operate its methods on MATLAB variables?

I'm trying to design a Wiener filter in Matlab for a deconvolution problem but I'm having a lot of problems. I have a gaussian white noise process with a variance of 1.2 and a impulse response which has length two. Its values are g(0) = 5 and g(1) = 4....

I'm trying to create a mask (or similar result) in order to erase pieces of a binary image that are not attached to the object surrounded by the boundary. I saw this thread (http://www.mathworks.com/matlabcentral/answers/120579-converting-boundary-to-mask) to do this from bwboundaries, but I'm having trouble making suitable changes to it. My goal...

This is what I tried: f = @(x) 0; for i = 1:n f = @(x) f(x) + x^i; end It seems to do the right thing, when I test it by putting in some values. But when print f I got this output f = @(x) f(x) + x^i...

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...

I have multiple 2D line plots in Matlab (they represent some wave moving through space). Each plot represents the wave at some time t. I want to animate through these plots (i.e. show the first plot for a fraction of a second, then show the next one, and the next,...