Answered
extract field from a structure problem
depending on the content, if scalar tmp=[DP1.P] or if not tmp={DP1.P}

7 years ago | 1

| accepted

Answered
How to solve this matrix?
>> P=[0.2 0.4 0.4; 1 0 0; 0.5 0.25 0.25] P = 0.2000 0.4000 0.4000 1.0000 0 0 0.5000 ...

7 years ago | 0

Answered
Intersection of three and more arrays
My FEX returns the index of the arrays

7 years ago | 0

| accepted

Answered
How to randomly choose 3 values ​​from the first column.
A(randperm(size(A,1),3),1)

7 years ago | 2

| accepted

Answered
How can I find a fit to my data points and using triangulation to approximate the planar area?
Quick and dirty fix, just discard outside delaunay triangles with long sides load('x-data.mat'); load('y-data.mat'); xy = [...

7 years ago | 0

Answered
Overcome for loops for fast processing
skin_rgb = 0; for i = [2000 : 2003,2008,2010:2011,2013:2015,2017:2018,2021,2024,2027:2041,2043,2045:2059,2061:2063] I = im...

7 years ago | 1

| accepted

Answered
calculation of a mean
splitapply(@mean,data,ceil((1:size(data,1))'/10))

7 years ago | 1

Answered
Combinations of a vector with replacement
A = [2 3 4] [A1,A2] = ndgrid(A); arrayfun(@(k) polyval([A2(k),A1(k)],10), 1:numel(A1)) [A1,A2,A3] = ndgrid(A); arrayfun(...

7 years ago | 1

| accepted

Answered
Rotate 3D axis camera perspective about arbitrary direction vector
Here is a demo to show using Camera parameters, I also put the rotation matrix R in comment. I find MATLAB parameters more intui...

7 years ago | 0

| accepted

Answered
How to efficiently multiply each element of a matrix with every other element of two other matrices, i.e. in least time possible?
[m,n] = size(A); AA = reshape(A,1,1,m,1,1,n); BB = reshape(B,1,m,1,1,n,1); CC = reshape(C,m,1,1,n,1,1); V = AA.*BB.*CC; V =...

7 years ago | 0

| accepted

Answered
Replace values in one column based on the content in several other columns.
A = [1 1 1 0; 1 2 1 1; 2 1 1 3; 1 1 1 3; 2 1 2 4] B = [1 1 1 1; 1 2 1 0] [b,loc] = ismember...

7 years ago | 0

| accepted

Answered
CAN I FIND FLOPS FOR A CODE WHICH I HAVE WRITTEN
If you can find an old R6.0 of MATLAB, and your code is able to run with it there is a command floops(). Since MATLAB use LAPAC...

7 years ago | 0

Answered
Creating a vector which goes across all x y and z values
The dot product between [0 2 0] and [x,y,z] is 2*y So just do dotresult = 2*y

7 years ago | 0

Answered
Creating a georeferenced polygon
You can get a linear connected contour (polygon) by C = contourc(lat,lon,double(isfinite(dro_dom_fill)),0.5*[1 1]); C = C(:,...

7 years ago | 0

Answered
how to find the first element that satisfy a condition in a matrix?
Try this for j = 1:ny idx_start(:,j) = find(Dwf(:,j)> 0.01,1,'first') ; idx_end(:,j) = find (Dwf(:,j) < 0 & (1:nx)...

7 years ago | 0

| accepted

Answered
Compiling with Matlab instead of interpreting
MATLAB calls FFTW library behind the scene, so if you are doing heavily FFT for convolution, there is not much speed penalty. I...

7 years ago | 1

| accepted

Answered
How to order vertices of a flat convex polygon in 3d space along the edge?
<</matlabcentral/answers/uploaded_files/140726/PolySorted.png>> xyz =[... -2.6055 1.1850 0.0880; -2.6320 1.170...

7 years ago | 3

| accepted

Answered
Overdetermined system of equations - 8 degree polynomial
If you rescale your data, making for example x coordinates between (-1,1) it might hep to get a better condition linear system. ...

7 years ago | 1

Answered
How to find the largest factor of a number using while loops?
largestfactor=floor(n/2); while largestfactor>0 if mod(n,largestfactor)==0 break end larges...

7 years ago | 1

| accepted

Answered
If i have array defined as G=(83 27 125 99 0 25 255 ..... ) .Is there any command or code to find S as defined below ?
correct ranging if the minimum of G starts from 0: clear S S(G+1) = 1:numel(G)

7 years ago | 0

Answered
Quaternions, Transformation Matrix
Such thing is straight forward in MATLAB q1 = reshape(q1,1,1,[]); q2 = reshape(q2,1,1,[]); q3 = reshape(q3,1,1,[]); ...

7 years ago | 0

| accepted

Answered
What is background technique of fsolve ?
The relevant information is in Algorithm part in the bottom of the <https://fr.mathworks.com/help/optim/ug/fsolve.html Doc>, jus...

7 years ago | 0

| accepted

Answered
How can I plot 3D surface x^3 + y^3 + z^3 = 1, where x, y, z are in unit closed interval in MATLAB ?.
<</matlabcentral/answers/uploaded_files/140679/xyzcube.png>> <</matlabcentral/answers/uploaded_files/140680/xyzcube.png>> ...

7 years ago | 1

Answered
Combining K matrices in one matrix
X = reshape(cat(3,a,b,c),[],3)

7 years ago | 1

| accepted

Answered
How to construct the n*n matrices, like below:
Such matrix is a FEM/discrete laplacian, and I strongly recommend using sparse matrix whene ever solving PDE. n = ... S ...

7 years ago | 0

Answered
How to solve 3 equations dependent each other?
_Actually i thought it is going to be easy but when i write the code for wx, i realized that wx is increasing with time but wz a...

7 years ago | 0

| accepted

Answered
Index exceeds the number of array elements (1) error
%assign initial gues to unknowns th3(k)=x(1);th5=x(2); th6=x(3);to=x(4); I think it should be ...

7 years ago | 0

| accepted

Answered
Interp1 returning NaN for ode45
V = interp1(V,t_interp,t,'pchip'); It looks arguments are swapped; I think it should be V = interp1(t_interp,V,t,'pchi...

7 years ago | 1

| accepted

Load more