Answered
Reshaping of 3-dimensional array to construct an isosurface
I just fix the code without knowing what is really your aim. I'm surprise you do all kind of kron and eigs and get lost in the u...

2 years ago | 0

Answered
Eig function and chol function returning wrong matrix factorization
You make two mistakes, please see comments (where "Bruno" appears) in this corrected code %------------------------------------...

2 years ago | 0

Answered
How to get subplots made of a group of already existing .fig
It seems to work for me % I invent this part for fig = 1:8 hf(fig) = figure(fig); plot(sin(linspace(1,fig))); s...

2 years ago | 0

Answered
How MATLAB fft processes data which length is not equal to 2^p (p = 1,2,...)
MATLAB FFT use FFT in the est library. The reference here explain the algorithm http://www.fftw.org/fftw-paper-ieee.pdf

2 years ago | 0

Answered
Extract numbers from a list
succeed = false; while ~succeed c = repelem(4,37,1); n = sum(c); r = rand(1,n); y = []; for i=1:n ...

2 years ago | 0

| accepted

Answered
Convert 1x1 cell array to double
Not sure if it's more efficient but it's shorter rttTime = str2num(rttTable.vectime{1})

2 years ago | 0

Answered
How to use the quadprog function for solving non-convex quadratic optimization problems in Simulink?
I'm not sure about simulink, but for MATLAB , you have only limited support for non-convex by quadprog: "The 'interior-point-co...

2 years ago | 0

Answered
Find the velocity of a travelling wave like behaviour
%s =load('solution.mat'); %SS = s.sol; % Create fake N and SS N = -20:0.1:20; v = arrayfun(@(x) x/(sqrt(1+x^2)), (1:40)/10...

2 years ago | 0

| accepted

Answered
Which triangulation Method is used for natural scattered interpolation?
Voronoi tessellation and Delaunay triangulation are two faces of the same coin. They can be derived one from another. https://ca...

2 years ago | 0

| accepted

Answered
How to get rid of this nested for cycles?
If you want to work with cell % simulating similar inputs: K = 3; H = 250; N = 50; B = 10; Q = cell(1,K); rng('default'...

2 years ago | 1

Answered
Edge Detection in a 2D Matrix
Do you want this load(websave('data.mat','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1446792/data.mat')) ...

2 years ago | 1

Answered
How to get rid of this nested for cycles?
There is no reason using cell, rather 4-dimensional array. Admitely the code is not clear if you don't keep track which dimensi...

2 years ago | 1

| accepted

Answered
smooth noisy data with spline smoothing
See those threads can help you https://www.mathworks.com/matlabcentral/answers/1772125-how-to-generate-a-smooth-derivative-afte...

2 years ago | 1

| accepted

Answered
Indexing nearest value to my coordinate
It is odd that you want to find the index of nc file data closest to the Station. It just sounds more natural to look for the o...

2 years ago | 0

Answered
The multiplication result by sum() and matrix multiplication are not the same
You cannot prevent the roundoff error to occur and operation order dependency. Even for the same computer the result can chang...

2 years ago | 0

Answered
Circular vortex with spin vectors
[x,y] = ndgrid(linspace(-1,1,10)); x = x(:)'; y = y(:)'; xy = [x; y]; r = vecnorm(xy, 2, 1); r(r > 1) = NaN; xyn = xy ./ ...

2 years ago | 1

Answered
how velocize it? (it's possibile to vectorize it?)
I don't know the memory requirement would go up if I vectorize the outer loop in a non-toy case. So I leave it for now. Ntrades...

2 years ago | 1

| accepted

Answered
Draw and color the intersection between two 3D surfaces?
It's sphere extruded by a cone x = linspace(-1.1,1.1,129); y = linspace(-1.1,1.1,129); z = linspace(0,1.1,129); [X,Y,Z] = me...

2 years ago | 0

Answered
Network adjacency matrix for connecting n node with probability p
Pretty similar to Torsen's solution. Adjust the density and no-loop p=0.1; n=30; A = GenerateAMat2(p, n); nnz(A)/numel(A) ...

2 years ago | 0

Answered
Network adjacency matrix for connecting n node with probability p
Method without loop, generate entire matrix, symmetrize then remove self-connexion p=0.4; n=10; A = GenerateAMat(p, n); ...

2 years ago | 0

Answered
How to find the index of an element ?
Compare with tolerance epss = 0:0.00001:0.1; tol = eps(0.1); i = find(abs(epss - 0.00208) < tol) % and if you are lazy to es...

2 years ago | 0

Answered
Flipping the elements of a vector
"For larger vectors [1:1e6] the second one gives "Out of memory. The likely cause is an infinite recursion within the program." ...

2 years ago | 0

Answered
How to vectorize?
Just to pull out the right answer (my previous answer applied on a WRONG calculation specified by OP) % vectorized method c = ...

2 years ago | 1

| accepted

Answered
How to vectorize?
If you want obscure code by avoiding for-loop E = rand(10,5) Tr = randi(size(E,1),9,size(E,2)) [r,c]=size(Tr); x=(1:3:r); ...

2 years ago | 1

Answered
abs cannot be used in problem-based optimization expression
Nevermind abs is not supported function https://www.mathworks.com/help/optim/ug/supported-operations-on-optimization-variables-e...

2 years ago | 0

| accepted

Question


abs cannot be used in problem-based optimization expression
Can someone tell me why I cannot use abs() in this simple setup. prob = optimproblem(); x = optimvar('x',1,1); y = 1; x0 = s...

2 years ago | 1 answer | 0

1

answer

Answered
How to put matrices defined earlier in "for loop" later
I have no idea if you expect this syms x p_1 p_2 r rho_alpha = (1/21).*[2 0 0 0 2 0 0 0 2;0 5-x 0 0 0 0 0 0 0;0 0 x 0 0 0 0 0...

2 years ago | 1

| accepted

Question


using feval or not?
I have function handle myfun I need to evalute I prefer using feval https://www.mathworks.com/help/matlab/ref/feval.html y = f...

2 years ago | 1 answer | 0

1

answer

Answered
Is it possible to programmatically suppress figure roll-over menu (zoom, rotate, etc)?
ax = gca; % your axe handle if you can get it other than gca set(ax,'Interactions',[])

2 years ago | 0

| accepted

Answered
How to get the current rotation angle of an object when using interactive vol=volshow(img3D)?
axehandle = gca [az,el] = view(axehandle)

2 years ago | 0

Load more