Answered

How to convert an optimization variable to symbolic variable?

You can use the evaluate() command to substitute in values.

How to convert an optimization variable to symbolic variable?

You can use the evaluate() command to substitute in values.

2 days ago | 0

Answered

Set elements in a 3D array to zero based on a condition

Qr(Qr<0)=0;

Set elements in a 3D array to zero based on a condition

Qr(Qr<0)=0;

3 days ago | 0

| accepted

Answered

reduction variables and evaluation order

First remember that each worker is assigned some consecutive subset of loop iterations. The worker will execute the iterations w...

reduction variables and evaluation order

First remember that each worker is assigned some consecutive subset of loop iterations. The worker will execute the iterations w...

3 days ago | 0

| accepted

Answered

max value of a function

In general I use: x= double(solve(diff(func))); This assumes there are no local min/max or saddle points. if i try to use max...

max value of a function

In general I use: x= double(solve(diff(func))); This assumes there are no local min/max or saddle points. if i try to use max...

3 days ago | 0

| accepted

Answered

Fastest way to compute a multiplication of matrices times a sequence of kronecker products

With this FEX package https://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-ma...

Fastest way to compute a multiplication of matrices times a sequence of kronecker products

With this FEX package https://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-ma...

3 days ago | 0

| accepted

Answered

I meet a formula about bilinear interpoltaion, but it not mention the 'int' in formula, how can I convert it to matlab code?

You could just use interp2.

I meet a formula about bilinear interpoltaion, but it not mention the 'int' in formula, how can I convert it to matlab code?

You could just use interp2.

3 days ago | 0

Answered

for loop storing the same variable

Because in every pass through the loop, you assign the result to the same location. Perhaps you meant, demodulated_power_vector...

for loop storing the same variable

Because in every pass through the loop, you assign the result to the same location. Perhaps you meant, demodulated_power_vector...

3 days ago | 0

| accepted

Answered

Error when using sptensor in parfor

You could try with ndSparse() instead of sptensor() https://www.mathworks.com/matlabcentral/fileexchange/29832-n-dimensional-sp...

Error when using sptensor in parfor

You could try with ndSparse() instead of sptensor() https://www.mathworks.com/matlabcentral/fileexchange/29832-n-dimensional-sp...

6 days ago | 0

| accepted

Answered

Calculate the mean of nonzero pixels and setting a threshold

fun=@(z) nanmean(z(z<99)); my_mean = accumarray(double(mask(:))+1, my_array(:),[], fun)

Calculate the mean of nonzero pixels and setting a threshold

fun=@(z) nanmean(z(z<99)); my_mean = accumarray(double(mask(:))+1, my_array(:),[], fun)

6 days ago | 1

Answered

Can I use a nearest neighbor extrapolation strategy with interp1?

If you want to mix interpolation and extrapolation methods, use griddedInterpolant instead: F=griddedInterpolant(1:5,'linear','...

Can I use a nearest neighbor extrapolation strategy with interp1?

If you want to mix interpolation and extrapolation methods, use griddedInterpolant instead: F=griddedInterpolant(1:5,'linear','...

7 days ago | 0

| accepted

Answered

Find unique number sets

A = [1 4; 2 3; 3 2; 1 4]; [B,iA]=unique(sort(A,2),'rows')

Find unique number sets

A = [1 4; 2 3; 3 2; 1 4]; [B,iA]=unique(sort(A,2),'rows')

7 days ago | 0

| accepted

Answered

How to find all possible 8x8 submatrices of a 13x8 matrix?

Using this File Exchange tool set, https://www.mathworks.com/matlabcentral/fileexchange/115340-block-transposition-permutation-...

How to find all possible 8x8 submatrices of a 13x8 matrix?

Using this File Exchange tool set, https://www.mathworks.com/matlabcentral/fileexchange/115340-block-transposition-permutation-...

7 days ago | 1

Answered

Plotting graph for specific columns and rows

plot(yourTable{1:4000,20}, yourTable{1:4000,60})

Plotting graph for specific columns and rows

plot(yourTable{1:4000,20}, yourTable{1:4000,60})

7 days ago | 0

| accepted

Answered

Class implementation such that assignment x=MyObj does in fact x=MyObj.prop1

You can't have precisely what you have asked for, but you can do this, classdef TestClass < handle properties pro...

Class implementation such that assignment x=MyObj does in fact x=MyObj.prop1

You can't have precisely what you have asked for, but you can do this, classdef TestClass < handle properties pro...

7 days ago | 0

| accepted

Answered

How to create a rectangular mask based on current code for making an elliptical mask

You could also just use poly2mask. This would avoid the overhead of imrotate. M=256; N=256; %Image dimensions diamMax=60; ...

How to create a rectangular mask based on current code for making an elliptical mask

You could also just use poly2mask. This would avoid the overhead of imrotate. M=256; N=256; %Image dimensions diamMax=60; ...

7 days ago | 0

Answered

How to create a rectangular mask based on current code for making an elliptical mask

I don't understand how your current code works, but you might consider modifying the code below, as appropriate: M=256; N=256...

How to create a rectangular mask based on current code for making an elliptical mask

I don't understand how your current code works, but you might consider modifying the code below, as appropriate: M=256; N=256...

7 days ago | 0

| accepted

Answered

Backslash does not provided the solution with the smallest 2-norm

In this case, we expect that MATLAB returns the solution x which has the smallest 2-norm, right? No, the backslash operator wil...

Backslash does not provided the solution with the smallest 2-norm

In this case, we expect that MATLAB returns the solution x which has the smallest 2-norm, right? No, the backslash operator wil...

7 days ago | 2

Answered

How to resample vectors of different length into the same length?

How can I achieve that? You can use interp1 Also should I resample to the biggest size out of the vectors or bring them all to...

How to resample vectors of different length into the same length?

How can I achieve that? You can use interp1 Also should I resample to the biggest size out of the vectors or bring them all to...

7 days ago | 0

Answered

How find the row number for different elements in a column?

As an example, suppose you wanted to find the first occurrence of a 2 in each column. Then one way would be, A=randi(10,10,5) ...

How find the row number for different elements in a column?

As an example, suppose you wanted to find the first occurrence of a 2 in each column. Then one way would be, A=randi(10,10,5) ...

7 days ago | 0

Answered

Help with DFT Algorithm (No FFT)

When I carry out this calculation I get the following: . No, because 1/3 of your xx are padded zeros. This will reduce your amp...

Help with DFT Algorithm (No FFT)

When I carry out this calculation I get the following: . No, because 1/3 of your xx are padded zeros. This will reduce your amp...

8 days ago | 2

| accepted

Question

Using find() is faster than direct logical indexing?

Does it make sense that using find() instead of direct logical indexing is faster in this example: A=randi(100,5e3,5e3); tim...

8 days ago | 1 answer | 0

Answered

How to call the row number of an element?

With find, but be mindful that direct logical indexing is often faster if you are seeking to modify the matrix. Compare: %Repla...

How to call the row number of an element?

With find, but be mindful that direct logical indexing is often faster if you are seeking to modify the matrix. Compare: %Repla...

8 days ago | 0

Answered

AUC or trapz for irregular shape that intersects itself

Perhaps as follows? p=polyshape(WL_1546La, WL_1546Fa); Areas=area(regions(p))

AUC or trapz for irregular shape that intersects itself

Perhaps as follows? p=polyshape(WL_1546La, WL_1546Fa); Areas=area(regions(p))

9 days ago | 0

Answered

Is it possible to loop through and set image pixels with a parfor loop?

If you have the Image Processing Toolbox, you should use imwarp to perform an image transformation.

Is it possible to loop through and set image pixels with a parfor loop?

If you have the Image Processing Toolbox, you should use imwarp to perform an image transformation.

9 days ago | 1

Answered

Why does filtering data before PCA improve results?

PCA applied to the transformed cluster should find PC1 close to L', and therefore the projections of the images on L' should be ...

Why does filtering data before PCA improve results?

PCA applied to the transformed cluster should find PC1 close to L', and therefore the projections of the images on L' should be ...

9 days ago | 0

Answered

how can I find the max value out of iterative for loop ?

Seems to be working: count=1; while 1 for i=1:20 x(i)= randi(87);% calculations end maxvalue(cou...

how can I find the max value out of iterative for loop ?

Seems to be working: count=1; while 1 for i=1:20 x(i)= randi(87);% calculations end maxvalue(cou...

10 days ago | 0

| accepted

Answered

Store m iterations of a variable in for loop

Perhaps as follows: ivals=1:step:m; J=numel(ivals); [LAT_3,LON_3,ALT_3]=deal(nan(1,J)); for j = 1:J i=ivals...

Store m iterations of a variable in for loop

Perhaps as follows: ivals=1:step:m; J=numel(ivals); [LAT_3,LON_3,ALT_3]=deal(nan(1,J)); for j = 1:J i=ivals...

10 days ago | 0

| accepted

Answered

How to generate a smooth derivative after fitting a curve to the data?

You can try some different choices of the smoothing parameter, load Data % using cubic spline pp = spline(x,y); derX= fnde...

How to generate a smooth derivative after fitting a curve to the data?

You can try some different choices of the smoothing parameter, load Data % using cubic spline pp = spline(x,y); derX= fnde...

10 days ago | 0

Answered

Using structures with Functions

@Stephen23's answer might be what you are looking for, but if you need the struct in scalar form for some reason, then the attac...

Using structures with Functions

@Stephen23's answer might be what you are looking for, but if you need the struct in scalar form for some reason, then the attac...

10 days ago | 1