Answered
Generate coordinates for plotting a hexagonal mesh with the nsidedpoly function
C=arrayfun(@edgesamp,1:6,'uni',0); C=vertcat(C{:}); x=C(:,1); y=C(:,2); n=numel(x); p0=nsidedpoly(6,'Radius',1); p=array...

4 years ago | 0

| accepted

Answered
is there any way for me to apply code to a figure?
You can get the x and y data that make up the plot as follows. h=findobj(gca,'Type','line') x=h.XData; y=h.YData; I would ...

4 years ago | 0

Answered
Build a matrix for each loop output
M=zeros(3,4); for j=1:3 As_prov=As.Asst>Asneg(j); i=find(As_prov,1,'first') M(j,1)=As.n1(i);...

4 years ago | 1

| accepted

Answered
How do you find the inverse of a matrix without the inv() command?
There is this File Exchange contribution: https://www.mathworks.com/matlabcentral/fileexchange/12692-adjugate-adjoint-of-a-squa...

4 years ago | 1

| accepted

Answered
Why do I get the error saying I did not assign values to a call? I did assign my values after getting them from a function though? Anyone able to help me out and explain?
The error message is complaining that you did not assign a value to P within atmos(). P is named as an output of atmos, [T, P,...

4 years ago | 0

Question


Loop-free histogramming of each column of an input matrix
Before there was histcounts(), we would use histc(), which is no longer recommended by TMW. But histc() could calculate the colu...

4 years ago | 1 answer | 0

1

answer

Answered
Digits that repeat in an n by m matrix
A = [ 9 5 2 1 5 3 3 2 2 5 1 8 3 1 7 4 3 2 2 6 ...

4 years ago | 1

| accepted

Answered
Digits that repeat in an n by m matrix
A = [ 9 5 2 1 5 3 3 2 2 5 1 8 3 1 7 4 3 2 2 6 ...

4 years ago | 0

Answered
Count 3D points in each block of a 3D grid
You could do like in the following example, which assumes 1x1x1 cells in a 500x500x500 grid. xyz=rand(100,3)*499+1; %random 3D ...

4 years ago | 0

Answered
Solve indefinite integral with unknown lower limit
Looks like there are 2 solutions. format long g T0=1650; rhs=1e-3*T0^2 + 11.66*T0 + 0.67e5/T0; p=[1e-3,11.66, -rhs, 0.6...

4 years ago | 0

Answered
How to use "@" functionhandle for multiple inputs? (to use with fmincon)
objective = @(p) sum( ( a - get_amps(a, p) ).^2); par0=[100,5000]; p_opt=fmincon(objective,par0);

4 years ago | 0

| accepted

Answered
"Too many input arguments" when calling a constructor with named arguments
Note the attached utility copyprops(). function obj = fet(varargin) constants = semiConstants; ...

4 years ago | 0

Answered
Generate all possible combinations of input vector Then store the input and outputs in each iteration in .mat file
Well, here are all the combinations. You can loop through the rows of Pd and save them after whatever processing you wish. You'v...

4 years ago | 0

| accepted

Answered
Stacking diagonal matrices generated from rows of other matrix
C=magic(4) c=C(:,2:4); [m,n]=size(c); p=m*n; D=zeros(p,n); D( (1:n:p)'+ (0:n-1)*(p+1) )=c(:)

4 years ago | 1

Answered
Stacking diagonal matrices generated from rows of other matrix
C=magic(4) c=C(:,2:4); [m,n]=size(c); D=repmat(eye(n),m,1); D(logical(D))=c(:)

4 years ago | 1

Answered
Compare numel of multiple variables
a = [1 2 3] ; b = [1 2 3 4] ; c = [1 2 3 4] ; L=cellfun(@numel,{a,b,c}); all_numel_equal = all(L==L(1))

4 years ago | 0

Answered
Compare numel of multiple variables
a = [1 2 3] ; b = [1 2 3 4] ; c = [1 2 3 4] ; isequal(numel(a),numel(b),numel(c))

4 years ago | 1

| accepted

Answered
Genetic Algorithm using ga command is giving solutions out of defined bounds.
[x,fval] = ga(@(K)pidtest1(G,dt,K),2,[],[],[],[],[1,1],[100,100],[],options);

4 years ago | 0

| accepted

Answered
How can I adjust the behavior of 'levenberg-marquardt' algorithm in fsolve?
There is no general pattern of sensitivity that you will see with either of the algorithms to any particular tolerance parameter...

4 years ago | 0

Answered
When I'm using the fmincon function to solve an optimization problem,the optimization result is always near the initial value. How to avoid this situation?
The initial value sets these variables to 1, and the solution results in these variables are all 1. If you are rounding your va...

4 years ago | 0

Answered
Select only some Index in matrix
The former approach is definitely better. It uses half as much memory and should be much faster for large var2.

4 years ago | 1

| accepted

Answered
How to improve sparse array indexed assignment in MATLAB?
Assigning into an existing sparse matrix is fundamentally a slow thing. If you are creating a matrix from scratch, use the spars...

4 years ago | 0

Answered
Finding out the size of x (so how many xi we have) in a function handle
One possibility, f1 = @(x) x(1)^2+x(2)^2+x(2)+x(3); str = extractBetween( func2str(f1),'x(',')'); dimension=max(str2doubl...

4 years ago | 0

| accepted

Answered
Finding out the size of x (so how many xi we have) in a function handle
No, not from the function handle itself. Note that your f1 and f2 work for vectors of any length>3, e.g., f1 = @(x) x(1)^2+x(2...

4 years ago | 0

Answered
Calculate % difference for 2 vectors into a matrix
I don't see any errors in your version, but this is shorter and faster: diffMat=abs( 1 - FR2./FR')*100;

4 years ago | 0

| accepted

Question


Is there a keyboard shortcut for deleting one character ahead of the cursor, instead of one character behind it?
Is there a keyboard shortcut for deleting one character ahead of the cursor, instead of one character behind it (backspace)? Bac...

4 years ago | 2 answers | 0

2

answers

Answered
Computing the jacobian of an anonymous function - MATLAB
On the File Exchange, there are numerical methods for approximating the Jacobian of a non-symbolic function using finite differe...

4 years ago | 0

Answered
How can I obtain the analytical expression (polynomial) of the spline curve from a curve fitting?
What I need is the polynomial of those spline A spline consists of many polynomials stuck together, not just one.Also, there ar...

4 years ago | 0

Answered
fit function not optimizing parameters
Loop over the discrete variables. Use fit() with respect to the continuous ones. for b=1:4 g = fittype(@(b,c,x) 1 - A*ex...

4 years ago | 0

| accepted

Answered
Generate all probability of non repeated combinations of .mat files
names=["One","Two","Three"]; N=numel(names); combs=cell(N,1); for i=1:N combs{i}=num2cell(nchoosek(1:numel(names),i),2); ...

4 years ago | 0

| accepted

Load more