Answered
Ploting vector perpendicular to a surface in a specific point
You are tricked by the scaling. If you want to observe the orthogonal by eye you should set the same scaling for x-y-z quiver3(...

5 years ago | 0

| accepted

Answered
How to suppress all the outputs during assignment of multiple variables with the same value? [To improve presentation]
X = imread('parrot.jpg'); X = num2cell(X,[1 2]); [R,G,B] = deal(X{:}); Or simply X = imread('parrot.jpg'); R = X(:,:,1); G...

5 years ago | 0

Answered
Scattered interpolation unexpected peaks in extrapolation results
You might appropriately rescale your x/y data before interpolation A=load('PV_curve.txt'); x=A(:,1); y=A(:,2); z=A(:,3); ...

5 years ago | 1

| accepted

Answered
How to set the constraints of L0- norm in linear programming?
Brute-force method % Original LP problem f = -ones(1,3); A=[-eye(3); eye(3)]; b = [0 0 0 0.3 0.4 0.5]'; fvalmin = I...

5 years ago | 0

| accepted

Answered
replace value in many colone to one value
Single line mtx*[1 0; 0 100; 0 10; 0 1]

5 years ago | 1

Answered
order a column of matrix respect to another column
c{1}=[1.25,5.05,7.2]; %so an double(3,1) c{2}=[1,2,3,4,5,6,7]; %so an double(7,1) i = interp1(c{2},1:length(c{2}),c{1},'near...

5 years ago | 1

| accepted

Answered
How do I assign a vector to a logical matrix?
AA=zeros(size(A),'like',B) AA(A)=B; A=AA; clear AA

5 years ago | 0

| accepted

Answered
How to speed up the way to find indexes from a large nx2 matrix and create a new matrix?
iS = intervalsSpeed; iS(1) = -Inf; iS(end) = Inf; iP = intervalsPower; iP(1) = -Inf; iP(end) = Inf; [~,iS] = histc(M(:,1), iS...

5 years ago | 0

| accepted

Answered
How to fix number of points of a cone using Matlab
Grid pattern The volume of the cone of base radius R and height h Vcone = pi*R^2*h/3 Assuming you dsicretize by small volume ...

5 years ago | 1

| accepted

Answered
How to set the constraints of L0- norm in linear programming?
Well the brute force method is to solve 3 LP problems assuming x1 = 0 x2 = 0 x3 = 0 and see which returns a solution.

5 years ago | 0

Answered
How to get random points from upper semisphere
Your code won't generate uniform point on half sphere, there is a bigger density on the north pole (try to generate with 10000 p...

5 years ago | 0

Answered
How to get random points from upper semisphere
Put ... [x,y,z] = sph2cart(azimuth,rvals,5); z = abs(z) ...

5 years ago | 0

| accepted

Answered
How to add a new field to a struct array inside a cell array
If your structures has the same fiednames then it is better to put them in structure array (s in the code below) rather than cel...

5 years ago | 1

Answered
Using a vector of indexes to acces a multidimensional vector
Check out this thread I provide three ways to convert nd-indexes to linear index.

5 years ago | 0

Answered
Returning Byte array of given substring
This should work function ByteConvertRxBuffer=ByteConvertRxBuffer(rx) ByteConvertRxBuffer = zeros(1,35,'uint8'); %starting arr...

5 years ago | 0

Answered
Get regular grid and points of a given stl file
I load the stl, cleanup the vertices, compute the face normal then I extract the top cap and interpolate on grid. % Read mesh a...

5 years ago | 1

| accepted

Answered
Integral2 for circular plot not working
Have you tried to evaluate >> polarfun(0,1) ans = NaN or >> cont(1,0) ans = NaN Fix those issue first.

5 years ago | 1

Answered
help with a vibratonal analysis code
"i keep getting an error message about 'The size of the indicated variable or array appears to be changing with each loop iter...

5 years ago | 0

Answered
How to set the sum of the absolute value of variables as inequality matrix and vector in linear programming?
You can intruduce slack variables y1, y2, y3 x1 <= y1 and x1 >= -y1 x2 <= y2 and x2 >= -y2 x3 <= y3 and x3 >= -y3 y1+y2+y3 <...

5 years ago | 0

| accepted

Answered
Finding Shortest Path through whole points without revisiting
You can look at TMW tuto on Traveling Salesman Prroblem https://uk.mathworks.com/help/optim/ug/travelling-salesman-problem.html...

5 years ago | 0

| accepted

Answered
Complete cell positions with NaN
AA{1,1} = [0 0 1 0 0 0 0]; AA{2,1} = [0 1 0 0]; AA{3,1} = [0 0 0 1 0 0 0 0 0]; i1=cellfun(@(a) find(a==1,1), AA); maxi1=ma...

5 years ago | 0

| accepted

Answered
Pick values around an index
% Test array A=randi([0 5],1,20) d=diff([A(:)==0; true]); idx0=find(d==-1); idx1=find(d==1); if length(idx1)>length(idx0)...

5 years ago | 1

Answered
While invoking the mcc executable does it suffice to only create an executable of the outermost function?
outermost function only mcc -m mainfunction.m

5 years ago | 1

| accepted

Answered
How to calculate max multiplication possibility of three adjacent numbers in 10*10 matrix?
% Test matrix A=randi([0 9],10,10) B=cat(3,movprod(A,3,1),movprod(A,3,2)); [maxB,imax]=max(B,[],'all','linear'); [i,j,k]=i...

5 years ago | 0

| accepted

Answered
fastest way to apply A\B on each matrix page
Why insist on ARRAYFUN, your for-loop is perfectly fine. ARRAYFUN is a "vectoriztion" scam. n = 100; A = rand(10,10,n); B = r...

5 years ago | 0

| accepted

Answered
Solving linear matrix equation
% Generate testexample of A, B (n x n) matrix such that A*B=A % Here A is generated to be symmetric but it doesn't matter n = ...

5 years ago | 1

| accepted

Answered
Unusual size of array
Try this sobj=sparameters('W=2um_L=20um.s2p'); s=sobj.Parameters; freq=sobj.Frequencies; y_params = s2y(s); y11=y_params(1,...

5 years ago | 0

Answered
negative continuous position on vector
BB = (1:length(AA))-find(AA==1,1)

6 years ago | 0

| accepted

Answered
Solving an ordinary differential equation including a rotation matrix
Might be you should rewrite ODE with the rotation not in term of 3x3 matrix but euler-rotation vector 3x1, then you should not w...

6 years ago | 0

Answered
Best-Practice: Vectorizing code dealing with sets of 3-element vectors, n x 3 or 3 x n?
My own preference is 3 x n element 2-D array. But I can understand why other format can be preferable in some other circumstance...

6 years ago | 0

Load more