I wanna write a neat code to compute the shortest distance between a point and any line segments in any directions. I understand that in many cases the shortest distance would be a line perpendicular from the point to the line segment and in some cas

I have one dataset in which some timestamps are missing. I have written code so far as below, x = table2dataset(Testing_data); T1 = x(:,1); C1 =dataset2cell(T1); formatIn = 'yyyy-mm-dd HH:MM:SS'; t1= datenum(C1,formatIn); % Creating 10 minutes of tim

I have in my file .mat three matrices, I need to delete one of them. I try clear ('Matrice1'), but it doesn't work.If you absolutely must completely delete the entire variable the most straightforward option is to load the data, remove the variable,

I must translate some Matlab code into Python 3 and I often come across ranges of the form start:step:stop. When these arguments are all integers, I easily translate this command with np.arange(), but when some of the arguments are floats, especially

I have a function like f = @(x) x(1).^2 + x(2); I want to draw its plot via surf, so I used meshgrid to generate input data: [x, y] = meshgrid(-2:.2:2); But if I try to pass it to the function like this z = f([x; y]) I get just a single value in resu

What I have I've a char array, defined by doing an strcat between two char arrays like this: coeficientes = strcat(coef_bin, coef_bin_comp) Then, I want to read each row and convert them to hex. I'm doing it like: for k=1:11 coef_binario = coeficient

I'm trying get an absolute path of all subfolders in project_dirs. project_dirs='D:\MPhil\Model_Building\Models\TGFB\Vilar2006\SBML_sh_ver\vilar2006_SBSH_test7\Python_project3_IQM_project'; all_project_dirs=dir(project_dirs) for i=all_project_dirs, f

My script on Windows 7 has multiple matlab figures (windows). When I periodically re-display the disparity figure, it always brings it to the front of the other windows. I want to leave it where it was, in the Z order. if isempty( disparity_map_figur

I want to use large arrays with 1.0e6 elements in other Matlab functions. Currently I am using small sized arrays and passing them as function input. I do not how much this passing of arrays going to affect the speed of my program when I use large ar

I would like to create several matrices to represent Hilbert matrices of different orders. The matrix will then be called by a function. However, error messages appeared saying that the function(GE) is not defined. But if I put the function on top of

Let us define any function handle foo: foo = @(x) x*2 I am trying to write a general function defFun that generates the n-th functional power of the function foo, i.e. n iterative calls of foo, in a way it can be stored in another handle function boo

does anybody know why the function countourf doesn't use the color corresponding to the maximum value anywhere in the plot area? if you try the code below, and then the command get(h_colorbar,'YLim') Matlab returns an upper limit which is not the hig

Essentially, I have a matrix of data with many "holes" represented by NaN, and I want to retrieve the indices of all NaN's that are clustered fewer than 4 times in a single column. e.g. with the matrix: A = 23 12 NaN 56 60 21 NaN 60 56 94 22 45

I hate having to ask this because I assume the answer must be simple, but I cannot for the life of me seem to track down the source. While trying to rewrite a function I ran across this problem: a = -j x = real(a) y = imag(a) y/x Which spits out Inf,

How do I get the result when '@' exist in the string will return 1 else 0. Now, I get the results of 0 0, although second string contain the character of '@'. A = {'@'}; B = {'http://www.mathworks.com/help/matlab/ref/strcmpi.html', 'http://www.mathwo

I am trying to compare two .mat files using the Matlab Comparison Tool. In the comparison result the NaN values are highlighted meaning they are different (even though they are not). How can one handle the NaN values when using the Matlab Comparison

I have a cell in Matlab with 5 strings in it, each string being a sentence and I want to pull out the number of special characters and the number of vowels in each sentence using a Matlab command. How would I do this? Here is my code: sentences={['Do

I am quite new to data analysis, so if this is a rookie question, I'm sorry, I am learning as I go. I have just started doing some work in variable star astronomy. I have about 100 files for every night of observation that all contain the same basic

I've solved an initial value differential equation and plotted the Y values given by ODE45. From the plot I can vaguely tell where the root should be, but in the given task I need to find it with great accuracy. My first guess was to adjust a polynom

I try producing a 14 x 5 subplot in Matlab, however the subplots have square axes so when displayed the subplots are not legible. Similarly, when I plot the results to pdf, the subplots are too small to read. How can I prevent this problem?If you don

I have a matlab gui that shall contain 4 plots. The first plot shall be updated if a different file is selected in a list. the other 3 shall only be visible (and be calculated) on request. However I fail to make plots 2-4 invisible after they have be

I have a vector of time (format h,min,sec,msec). TIME_= [120844.950000000 120853.870000000 120854.120000000 120854.370000000 120854.620000000 120854.860000000 120855.100000000 120859.980000000 120900.220000000 120900.490000000 . . . 121024.420000000

I'm running an algorithm to segment part of an image using morphological operations. I end up with a 2D binary image that represents the segmentation results. Namely, the mask. My question is how to plot the original image and the mask overlay in col

I have a matrix which is 36 x 2, but I want to seperate the elements to give me 18, 2 x 2 matrices from top to bottom. E.g. if I have a matrix: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... ... I want to split it into seperate matrices: M1 = 1 2 3 4 M2 = 5 6

Hi I'm rewriting a script from MATLAB to C++ using armadillo library for linear algebra and matrix. for getting more or less the same output i called cout method: cout.precision(4); cout.setf(ios::fixed); but i'm getting different result: Matlab resu

I have a problem dealing with 3rd dimension plot for three variables. I have three matrices: Temperature, Humidity and Power. During one year, at every hour, each one of the above were measured. So, we have for each matrix 365*24 = 8760 points. Then,

I am new to MATLAB, i wanted to know that can i extract a part of image from inside of a specified boundary,based on distinguishing color(red boundary in my case),The function,first traces the boundary of the image,then it extracts that part of image

I am trying to take a matrix and normalize the values in each cell around the average for that column. By normalize I mean subtract the value in each cell from the mean value in that column i.e. subtract the mean for Column1 from the values in Column

I want to vectorize the following MATLAB code. I think it must be simple but I'm finding it confusing nevertheless. r = some constant less than m or n [m,n] = size(C); S = zeros(m-r,n-r); for i=1:m-r+1 for j=1:n-r+1 S(i,j) = sum(diag(C(i:i+r-1,j:j+r-

I wonder how to get quotient in integer division in MATLAB? Thanks and regards!Use idivide: C = idivide(A, B) is the same as A./B except that fractional quotients are rounded toward zero to the nearest integers. There's a third optional parameter for