Answered
how to convert 4D into 3D?
If you mean you want the i-th 3D frame of the 4D data, then, frame_i=cropVol(:,:,i)

4 years ago | 0

Answered
Retrieve cartesian coordinates from a 3D shape surface
Call ellipsoid with outputs, [X,Y,Z] = ellipsoid(xc,yc,zc,xr,yr,zr)

4 years ago | 1

| accepted

Answered
Calculating the value, excluding nan
subset=1993<=y & y<=2021; datasub=data_crsp(subset,7); ysub=y(subset)-1992; stockreturn=splitapply(@(z)mean(z,'omitnan'),...

4 years ago | 0

Answered
Finding the value according to row number
data_crsp(dr(:,1),2)

4 years ago | 0

| accepted

Answered
How do I set coefficient variables in Fittype that was generated in Fitting toolbox?
Instead of a fitType object, use an anonymous function like in this example, https://www.mathworks.com/help/curvefit/fit.html#b...

4 years ago | 0

| accepted

Answered
how to compare two consecutive values in a matrix
M=(diff(temp2,1,2)<=0);

4 years ago | 0

Answered
How to detect corners of irregular binary shape?
You might try pgonCorners from the File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/74181-find-vertices-in-i...

4 years ago | 0

| accepted

Answered
How to automate the matrix-vector multiplication using the index of a vector?
m = 50; a = 5; b = 2; c = 2; J = [diag(a*ones(1,m)) + diag(b*ones(1,m-1),1) + diag(c*ones(1,m-1),-1)]; syms y [m,1] ex...

4 years ago | 0

Answered
How to get a matrix which acquires a pixel values along a spiral trajectory of Image.
sz=size(Image); J=sub2ind(sz,x,y); I=(1:numel(x))'; C=sparse(I,J,1);

4 years ago | 0

| accepted

Answered
operation on single elements in MATLAB
x=-2:1:2; %coordinates x n=length(x); y=x.^2; %coordinates y z=[x;y] interDistances=vecnorm(diff(z,1,2),2,1) %the result...

4 years ago | 1

| accepted

Answered
Finding the max number of non-zero repeating elements for each row in a large matrix
This should be fine for the uint8 case. For the uint16 case, it might strain RAM. A = [0 0 2 2 3; 0 1 3 3 3; 0 0 0 ...

4 years ago | 1

Answered
Finding the max number of non-zero repeating elements for each row in a large matrix
size(A,2) is relatively small, That being the case, I'd just use a loop: A = [0 0 2 2 3; 0 1 3 3 3; 0 0 0 0 0; ...

4 years ago | 2

| accepted

Answered
Two easy questions (But I am confused)
No need for (explicit) loops: S=rand(100); Sdiag=diag(S); cellstr("Row "+(1:100))

4 years ago | 1

| accepted

Answered
Does the initial population matrix have to satisfy constraints genetic algorithm matlab
Will MATLAB be able to automatically weed out the childs which do not satisfy the constraints? GA satisfies inequality and nonl...

4 years ago | 0

Answered
how to fix this error 'interp2'
Because your first argument to interp2 is a matrix while the second is a scalar.

4 years ago | 0

Answered
Why does complex number sign change?
Because it is equivalent to 2-1/(2i). In all likelihood, you intended to do this: a=2-(1/2)*i

4 years ago | 0

| accepted

Answered
How to specify breaks for spline fitting?
One way, xknots=... %specify the break points fun=@(y,xdata)spline(xknots,y,xdata); y0=zeros(1,numel(xknots)); y=...

4 years ago | 0

Answered
fmincon variable is start value
You didn't include everything we need to run the code (e.g., Strompreis2020.txt) however here are some guesses: (1) Your choice...

4 years ago | 0

| accepted

Answered
Optimize GPU code with nested pagemtimes
I don't think you need either a loop or a second pagemtimes call. Wr=reshape(W,16,1000); Qr=reshape(Q,16,16,2000); M=sum(pa...

4 years ago | 1

| accepted

Answered
how reduce the y axis value?
Use ylim, e.g., ylim([0.05,0.2])

4 years ago | 0

Answered
How to regularize the Levenberg-Marquardt algorithm in lsqnonlin?
You can append the square root of the regularization term to the vector . However, your objective function does not look differe...

4 years ago | 0

Answered
Calculating mean across a column and then subtracting it from all observations based on a row condition
G=findgroups(data(:,2)); Means=splitapply(@mean, data(:,6),G); data(:,6)=data(:,6)-Means(G);

4 years ago | 0

Answered
Constrained regression with constrains on the slopes
AA=log(K(:)./L(:)); bb=log(Q(:)./A(:)./L(:)); alpha=min( max(AA\bb,0) ,1 ); beta=1-alpha;

4 years ago | 0

Answered
using a for loop to find the mean of a set of data
out = mean( reshape(TSMo,7,2,6) ,2); out=out(:);

4 years ago | 0

| accepted

Answered
Trouble saving workspace variables to a file in a certain path.
save( fullfile('MyFiles/Data',filename) ,'var1','var2');

4 years ago | 0

| accepted

Answered
Is it possible to (non-linear) minimize x^y by choosing both x and y?
Why does the problem-based approach not "translate" the problem "correctly" in this case ?...I just cannot understand that the p...

4 years ago | 0

Answered
Reshaping data from a MxN matrix to three vectors that preserve M, N and mxn value
sz=size(yourMatrix); [X,Y]=meshgrid(1:sz(2),1:sz(1)); x=X(:); y=Y(:); value=reshape(yourMatrix',[],1); %3 vectors

4 years ago | 0

Answered
Open parallel pool within workers / Hierarchichal parallel runs
So, first of all, you shouldn't be calling parpool inside your fitness function. That should happen before the optimization star...

4 years ago | 0

| accepted

Answered
Is it possible to (non-linear) minimize x^y by choosing both x and y?
w = optimvar('w','Lower',log(1.01),'Upper',log(100)); %w=log(x) z= optimvar('z','Lower',sqrt(1.01),'Upper',sqrt(2)); %z=sqrt(y...

4 years ago | 0

Answered
Find out whether a 2D line (y = a*x + b) intersects with a square without using "solve" (I need something faster)
Sort of like William's, but faster for some reason: % example line parameters: a = 1.61; b = -3.1; % example square paramet...

4 years ago | 2

| accepted

Load more