Respondida
Please help with this multiplication problem
You can multiply directly. Example: [m,n,r]=deal(3,4,2); A=rand(m,1,r); B=rand(1,n,r); C=A.*B; whos A B C

alrededor de 1 año hace | 0

| aceptada

Respondida
sub2ind() errors out with NaN inputs - handled differently since R2024a
You can get the old behavior back if you need it, Sub2Ind([ 3 5 7], [ 3 3], [2 2], [1 nan]) function out=Sub2Ind(sz,vararg...

alrededor de 1 año hace | 1

| aceptada

Respondida
Non-linear constraints format for GA using solve function
I would formulate it as, N=numel(Pos_Input_mtx); problem.Constraints.c1=abs(Pos_Input_mtx(:)-Pos_Input_mtx(:)') >= (1-eye(N)...

alrededor de 1 año hace | 0

| aceptada

Respondida
Summing function handles of multiple variables across one of the variables
Nesting function handles n-fold is going to be very inefficient, and is usually not a good idea. Usually, it is best to vectoriz...

alrededor de 1 año hace | 0

Respondida
Error using trainNetwork Invalid training data. For classification tasks, responses must be a vector of categorical responses. For regression tasks, responses must be a vector
Instead of using Matlab's dicePixelClassificationLayer, you can try the following custom output layer: classdef GeneralizedDice...

alrededor de 1 año hace | 0

Respondida
Ifft2 results do not match that of irfft2 in Pyhton
I'm not a Python user, but if rfft2 only gives you positive x-frequencies, I would imagine it also only gives you positive y-fre...

alrededor de 1 año hace | 0

Pregunta


Three dots at the end of a line of code
Why does one of my lines of code have three dots enclosed in a box? What does it mean? Clicking on it does nothing.

alrededor de 1 año hace | 1 respuesta | 0

1

respuesta

Respondida
Looking for linear system Ax=0 precision improvements
s=max(abs(A),[],1); x = null(A./s)./(s')

alrededor de 1 año hace | 0

Respondida
Finding x and y values of minimum z in 2-variable function.
The continuous minimum can't be at (5,2) as you claim. Direct evaluation shows that the value of z at (5.5,10) is lower. loopi...

alrededor de 1 año hace | 0

Respondida
Using fft and ifft with less frequencies than input points
What I would want to do, is to insert an N, f.e. N=100, but get an array 10001x1. %Grid Nx = 100; L = 10; dx = L/(Nx-1); ...

alrededor de 1 año hace | 0

Pregunta


Why does the Code Analyzer flag this as an error?
Why does the Code Analyzer flag this code as an error? It runs fine: try error("It's bad") catch ME warning('Error...

alrededor de 1 año hace | 2 respuestas | 0

2

respuestas

Respondida
How to fastly calculate this real number matrix manipulation?
e=(1:A)'; I=reshape(e,1,1,[]) == repmat( e,1,B); Xp=permute(X,[3,2,1]); D=X./(X-Xp); D(I)=1; M = ipermute( prod(D,1) ,[...

alrededor de 1 año hace | 0

Respondida
How to solve the error generated while defining custom FFT layer?
Your predict() method is written to expect that the input X will be a cell array. It's not clear why you expect this, but you sh...

alrededor de 1 año hace | 0

| aceptada

Respondida
How do I edit a loop to be able to store the variables and outputs used in each loop in a way which can be graphed?
D = 0.3 k = 0.0002 Rvalues = 10^4:10^5:10^8; nR=numel(Rvalues); X=nan(1,nR); for i=1:nR R=Rvalues(i); ...

alrededor de 1 año hace | 0

Respondida
reshape 4-dimension array
Download this File Exchange package, https://www.mathworks.com/matlabcentral/fileexchange/115340-block-transposition-permutatio...

alrededor de 1 año hace | 0

Respondida
Speed up this bottleneck line of code
If you can construct c in transposed form, there are some savings to be had, n = 10000; m = 5000; k = 20; a = rand(n,m);...

alrededor de 1 año hace | 0

| aceptada

Respondida
nonlinear spline fit with unknown upper bound of interpolation domain
The upper bound is way larger than the fitted parameters at x < 6, causing an extremly large curvature at x > 6 which makes the ...

alrededor de 1 año hace | 0

| aceptada

Respondida
Differentiating in one direction using FFT2
fft2(u) is equivalent to fft( fft(u,[],1) ,[],2), if that helps at all. Truthfully, it doesn't appear that you need to use fft2...

alrededor de 1 año hace | 0

| aceptada

Respondida
need to vectorize efficiently calculating only certain values in the matrix multiplication A * B, using a logical array L the size of A * B
Is v much smaller than m or n? If so, one approach might be with an outer product decomposition: L=sparse(L); %if L was not pre...

alrededor de 1 año hace | 1

Respondida
shared colorbar for specific plots in tiledlayout
Using nestedLayouts from the File Exchange, https://www.mathworks.com/matlabcentral/fileexchange/161736-grids-of-tiled-chart-la...

alrededor de 1 año hace | 0

Respondida
MATLAB Optional Function Arguments
Using the arguments block is more robust, but I'm unable to find a way to make multiple inputs independently optional. The way ...

alrededor de 1 año hace | 3

| aceptada

Respondida
Set number of rows in output variable using indexing within for loop, add variable to new table
I would like to put the two calculated variable columns directly after the variable column in the original table. And you want ...

alrededor de 1 año hace | 0

Respondida
What happens if the termination condition is satisfied before the constraint in matlab's fmincon?
The only time fmincon will stop without satisfying the constraints (within ConstraintTolerance) is if the MaxItertions or MaxFun...

alrededor de 1 año hace | 0

| aceptada

Respondida
How to remove columns in very large matrices.
Use a sparse matrix, if applicable. matrix=sprand(1750000 , 2000, 1000/1750000); whos matrix tic; matrix(:,1:3:end)=[]; ...

alrededor de 1 año hace | 0

Pregunta


Suppress uitable cell borders
In Excel, there are buttons to select particular spreadsheet cell borders and hide them. Is there an analogous way to suppress t...

alrededor de 1 año hace | 1 respuesta | 0

1

respuesta

Respondida
How to find the mask boundaries?
[Y,X,Z]=find(Mask); S=X+Y+Z; [~,i]=min(S); [~,j]=max(S); [Xmin,Ymin,Zmin, Xmax,Ymax,Zmax] =deal( X(i), Y(i), Z(i), X...

alrededor de 1 año hace | 0

| aceptada

Discussion


Why doesn't MathWorks put its utility files in private\ folders?
On my computers, this bit of code produces an error whose cause I have pinpointed, load tstcase ycp=lsqlin(I, y, Aineq, bineq)...

alrededor de 1 año hace | 4

Respondida
How to restart a new backgroundPool
delete(pool) pool = backgroundPool;

alrededor de 1 año hace | 0

Respondida
Slim code for smoothing spline fit with predefined knots, concavity and monotonicity
One path would be to obtain the matrix form for the spline interpolator, which I do in the example below using func2mat from th...

alrededor de 1 año hace | 1

| aceptada

Respondida
"isfield" for hidden field in optimoptions
One way: options = optimoptions(@fsolve,'JacobPattern',speye(5)); isNonDefault = ~isequal(options.JacobPattern, optimoption...

alrededor de 1 año hace | 1

Cargar más