Answered
How to divide a 400x800 matrix to 8x8 blocks?
Processing is usually faster if you keep the data in numeric form. Using this FEX download, https://www.mathworks.com/matlabce...

3 years ago | 0

Answered
How to divide a 400x800 matrix to 8x8 blocks?
Easier to use mat2tiles from this FEX download, https://www.mathworks.com/matlabcentral/fileexchange/35085-mat2tiles-divide-ar...

3 years ago | 0

Answered
I have a matrix. I want to count number of only those zeros which are lying between 2 sets of consecutive nonzero values on each side. How to do? Desired result given below
Using this FEX download, https://www.mathworks.com/matlabcentral/fileexchange/78008-tools-for-processing-consecutive-repetition...

3 years ago | 0

Answered
delete special characters (\ / : * " < > |) in char
One way: name_1 = '<Hello World>'; pat=num2cell('\/:*"<>|'); name_1=erase(name_1,pat)

3 years ago | 0

| accepted

Answered
delete special characters (\ / : * " < > |) in char
One way: name_1 = '<Hello World>'; tf=ismember(name_1, '\/:*"<>|'); name_1(tf)=''

3 years ago | 1

Answered
Change a repeated number with the times the number is repeated in an array.
yourCell={[8.1,2.7,8.1,8.1,2.7]; [6.3 6.3,4,5,6.3]} result = cellfun(@fun, yourCell,'un',0) function y=fun(x) ...

3 years ago | 0

| accepted

Answered
I cannot run the "fmincon" solver.
error = norm(T_gas_outlet_est - T_gas_outlet).^2;

3 years ago | 0

Answered
array of anonymous function
clear obj for k=3:-1:1 obj{k} = @(V) I_fun(V, I0, IL, Rs, Rp, Vt_Ta) - target_value; fplot(obj{k},[0 55],'LineWidth',...

3 years ago | 0

| accepted

Answered
delete columns inside a cell based on null elements
map = cellfun('isempty',union_cell) tf=all( map(3:5,:),1); union_cell(:,tf)=[]

3 years ago | 0

| accepted

Answered
An alternative for strlength function for MATLAB 2013
There were no string data types back then, only char vectors, so you could just use length() or numel().

3 years ago | 1

| accepted

Answered
How can I solve this problem? "Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 8.375012e-18"
I believe the error originates from avec = Mm\b If so, it is because the Mm matrix is singular. The solution would be to make i...

3 years ago | 0

Answered
How can I record data from a parfor loop into an array?
Why is this not possible From the documentation for sliced variables (which array is supposed to be in this case): Form of Ind...

3 years ago | 1

| accepted

Answered
Alphashape boundary detection not working as desired
Try bwlalphaclose() from this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/90762-further-tools-for-ana...

3 years ago | 0

Answered
Getting Not Enough Input Arguments error
My guess is that strcmp(AttributeIndex,ESIDString) is returning false and therefore no arguments are being given as input to cel...

3 years ago | 0

Answered
unpack cell array of letters to be plugged into individual-cell rows, in a vector
load infon2 c=infon2(:,end); L=max(cellfun(@numel,c)); for i=1:numel(c) c{i}(end+1:L)=""; end c=num2cell(vertcat...

3 years ago | 0

| accepted

Answered
surface fitting using a self-defined function
Your model function is not supposed to assume that the xy samples are drawn from a Cartesian grid lattice. ft = fittype(@(a,b,c...

3 years ago | 0

| accepted

Answered
Operator '+' is not supported for operands of type 'function_handle'.
It's a bad idea (i.e. very inefficient) to add two functions together, however, the proper way would be as follows: g=@(x)x+1; ...

3 years ago | 0

Answered
Error while converting polyshape into double
You have pre-allocated ShipImg as a numeric double float vector, ShipImg = ones(1,length(t)); %a double vector of ones Then i...

3 years ago | 0

| accepted

Answered
How to find the indices of minimum value in a 4D matrix?
[lowestValue,locmin]=min(A(:)) [i,j,k,l]=ind2sub(size(A), locmin); %indices of min

3 years ago | 0

| accepted

Answered
I have curve fitting in matlab. My graph were all good when not add scatter in the graph. However, when i add scatter coding, the graph were not remain it origin.
It's hard to compare the two plots, because the x- and y-axes ranges are different in each. I suspect if you made the ranges the...

3 years ago | 0

Answered
can I pass these nonlinear constraints to lsqnonlin?
Most of the f(x,y) that I am working on are indeed of the form f(x,y)=h(x)+g(y). If this is true, then ensuring the convexity o...

3 years ago | 0

Answered
How to check neighbouring elements in a 2D array
load Image BW=bwareaopen(~BW,100); se=ones(7); BW=medfilt2(BW,size(se)); BW=bwareaopen(BW,100); BW=~bwareaopen(~BW,10...

3 years ago | 0

| accepted

Answered
Find four input combinations with the same output value, and find the one that minimizes the cost function.
It would simply be, Bopt=min(B(A==Astar)); [x_sol,y_sol,z_sol,w_sol ] = ind2sub(size(A), find(B==Bopt));

3 years ago | 0

| accepted

Answered
How to guess initialization parameters for non-linear curve fitting to get the best fit?
Re-arrange the equation as follows y = a*b*c*x^2 + (a-y*b*a)*x = C*x^2 + D*x Assume C and D can be treated as constants a...

3 years ago | 0

Answered
Why does polyfit gives two outputs?
It doesn't give 2 outputs unless you call it with 2 output arguments. The one output that it is giving you is a vector with 2 co...

3 years ago | 0

| accepted

Answered
How can i pull a matrix out of matrix with indices?
Do it a completely different way. Example A=rand(5) B=rand(5) condition=A<0.5; B(condition)=0

3 years ago | 0

| accepted

Answered
bilinear extrapolation based on interp2
Although you've been advised against it, if you truly must extrapolate bilinearly then griddedInterpolant will do it for you, [...

3 years ago | 0

| accepted

Answered
Find the central line (midpoint) of a sinusoidal wave
yline(mean(y))

3 years ago | 1

| accepted

Answered
Least Squares with constraint on absolute value
You'll need to write the problem in terms of the real-valued components xi and xr of x, x=xr+1i*xi Once you do that, your abso...

3 years ago | 0

Answered
how can I delete zeros after virgule?
floor([0.254 0.435]*10)/10

3 years ago | 0

| accepted

Load more