Answered

How to display all decimal numbers for floating numbers?

Try this fprintf('num1+num2 = %1.16g\n',adding_num1_and_num2)

How to display all decimal numbers for floating numbers?

Try this fprintf('num1+num2 = %1.16g\n',adding_num1_and_num2)

9 månader ago | 0

| accepted

Answered

randomly divide vector into 2 parts.

For the record, here is how I would do: n = size(index_rating,1); i = randperm(n,round(training_data*n)); dataTraining = in...

randomly divide vector into 2 parts.

For the record, here is how I would do: n = size(index_rating,1); i = randperm(n,round(training_data*n)); dataTraining = in...

9 månader ago | 2

Answered

Conditioning bivariate gaussian distribution

There a few issues with your code. First INTEGRAL is integration of a scalar function, you cannot integrate a vector function. ...

Conditioning bivariate gaussian distribution

There a few issues with your code. First INTEGRAL is integration of a scalar function, you cannot integrate a vector function. ...

9 månader ago | 0

| accepted

Answered

randomly divide vector into 2 parts.

Always post complete code that can run. don't less us geuss what is the size/class of the inputs First assumption: non_zero_ent...

randomly divide vector into 2 parts.

Always post complete code that can run. don't less us geuss what is the size/class of the inputs First assumption: non_zero_ent...

9 månader ago | 1

Answered

Filling area between more curves

Change accordingly to suit your need. tt = linspace(0,2*pi,361); xy = [2*cos(tt); 4*sin(tt)]; close all hold on pl...

Filling area between more curves

Change accordingly to suit your need. tt = linspace(0,2*pi,361); xy = [2*cos(tt); 4*sin(tt)]; close all hold on pl...

9 månader ago | 3

| accepted

Answered

how to change axis of a matix?

load('testdata.mat'); Ufun = @(X,Y,Z) X; Vfun = @(X,Y,Z) Y./(Z+200); [X,Y,Z] = ndgrid(x,y,z); U = Ufun(X,Y,Z); V = Vfun...

how to change axis of a matix?

load('testdata.mat'); Ufun = @(X,Y,Z) X; Vfun = @(X,Y,Z) Y./(Z+200); [X,Y,Z] = ndgrid(x,y,z); U = Ufun(X,Y,Z); V = Vfun...

9 månader ago | 0

| accepted

Answered

how to find rows and columns without using size

[numel(prod(A,2)) numel(prod(A,1))] % prod instead of sum for a change

how to find rows and columns without using size

[numel(prod(A,2)) numel(prod(A,1))] % prod instead of sum for a change

9 månader ago | 0

Answered

how to find rows and columns without using size

for 2D array p=numel(A); if p==0 try r = A(1,:); n = 0; m = numel(A*zeros(0,1)); catch ...

how to find rows and columns without using size

for 2D array p=numel(A); if p==0 try r = A(1,:); n = 0; m = numel(A*zeros(0,1)); catch ...

9 månader ago | 0

Answered

how to assign the equality relationship for the elements symmetry to the diagnoal of a matrix

% random test matrix A = rand(4) % symmetrize of A by copying the lower part to upper part B = tril(A)+tril(A,-1).' for ...

how to assign the equality relationship for the elements symmetry to the diagnoal of a matrix

% random test matrix A = rand(4) % symmetrize of A by copying the lower part to upper part B = tril(A)+tril(A,-1).' for ...

9 månader ago | 0

| accepted

Answered

How to add two values to a matrix each five values of that matrix in order to have a new matrix?

XY = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15]: r = ones(size(XY)); r(5:5:end) = 3; XYZ = repelem(XY,r) Note if ...

How to add two values to a matrix each five values of that matrix in order to have a new matrix?

XY = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15]: r = ones(size(XY)); r(5:5:end) = 3; XYZ = repelem(XY,r) Note if ...

9 månader ago | 2

Answered

How to set disableDefaultInteractivity for all axes?

For R2019b all the tricks found previously no longer work. I found this one does the trick set(groot,'defaultAxesCreateFcn', ....

How to set disableDefaultInteractivity for all axes?

For R2019b all the tricks found previously no longer work. I found this one does the trick set(groot,'defaultAxesCreateFcn', ....

9 månader ago | 2

Answered

determine minimum from the first column values of matrix and removing the rest of the rows

[~,imin] = min(E(:,1)); G = E(imin,:)

determine minimum from the first column values of matrix and removing the rest of the rows

[~,imin] = min(E(:,1)); G = E(imin,:)

9 månader ago | 0

| accepted

Answered

selecting rows from C with associated values in D, while using A and B values as references to produce E and F matrices

A = [1 2]; B = [1 3]; C = [ 1 19 18 4 3 0 0 0 0 0 0; 1 19 2 17 6 7 5 4 3 2 0; 1 16 15 17 6 7 5 4 3 2 0; ...

selecting rows from C with associated values in D, while using A and B values as references to produce E and F matrices

A = [1 2]; B = [1 3]; C = [ 1 19 18 4 3 0 0 0 0 0 0; 1 19 2 17 6 7 5 4 3 2 0; 1 16 15 17 6 7 5 4 3 2 0; ...

9 månader ago | 0

| accepted

Answered

Placing annotations at specific xy coordinates

There are several tool on File Exchange, such as this one

Placing annotations at specific xy coordinates

There are several tool on File Exchange, such as this one

9 månader ago | 0

Answered

C/Fortran callback to MATLAB

Not sure what you mean by "Callback". Callback to me is kind of event trigger function like an SW interruption. Anyway if you h...

C/Fortran callback to MATLAB

Not sure what you mean by "Callback". Callback to me is kind of event trigger function like an SW interruption. Anyway if you h...

9 månader ago | 0

Answered

Main diagonal operations problem

Here is a method that has two advantages: without the need of Roger's FEX randfixedsum Produce matrix with rigourous uniform c...

Main diagonal operations problem

Here is a method that has two advantages: without the need of Roger's FEX randfixedsum Produce matrix with rigourous uniform c...

9 månader ago | 1

Answered

Huge matrix with Nchoosek

You became real "Patient" now? Good! Then run this look at the screen and wait until it stops. If your type Ctrl C or kill MATLA...

Huge matrix with Nchoosek

You became real "Patient" now? Good! Then run this look at the screen and wait until it stops. If your type Ctrl C or kill MATLA...

9 månader ago | 1

Answered

Position of the left nearest one value in a vector

v = [0 0 1 0 0 0 1 1 1 1 0 0 1 1 1 0 0 1 0] % requirement: it must start with 0 Method 1 i0=find(v==0); i1=find(v==1); [~,lo...

Position of the left nearest one value in a vector

v = [0 0 1 0 0 0 1 1 1 1 0 0 1 1 1 0 0 1 0] % requirement: it must start with 0 Method 1 i0=find(v==0); i1=find(v==1); [~,lo...

9 månader ago | 1

Answered

Max function working for a sample of images but not all

Sato's example code [~,idx]=max(A,[],7) No the correct call is [~,idx]=max(A,[],3) You take the max along the third dimensio...

Max function working for a sample of images but not all

Sato's example code [~,idx]=max(A,[],7) No the correct call is [~,idx]=max(A,[],3) You take the max along the third dimensio...

9 månader ago | 0

| accepted

Answered

kron function application but in 3d

A(:,:,1)= [1 2; 3 4]; A(:,:,2)=[5 6; 7 8] B = repelem(A,1,2,2)

kron function application but in 3d

A(:,:,1)= [1 2; 3 4]; A(:,:,2)=[5 6; 7 8] B = repelem(A,1,2,2)

9 månader ago | 0

Answered

How to use a 2D index to create a 3D array from a 4D array?

It's amazing you all ask the same question, it must have some competition somewhere in the world (china?) about the topic of pro...

How to use a 2D index to create a 3D array from a 4D array?

It's amazing you all ask the same question, it must have some competition somewhere in the world (china?) about the topic of pro...

9 månader ago | 1

Answered

how can i add two matrix vertically with different column

I would do with the old well-served for-loop C={A B}; % put the list of your matrices here m=cellfun('size',C,1); n=cellfun...

how can i add two matrix vertically with different column

I would do with the old well-served for-loop C={A B}; % put the list of your matrices here m=cellfun('size',C,1); n=cellfun...

9 månader ago | 1

Question

deprecated javacomponent and javaframe

Starting from R2019b we are warned that javacomponent and javaframe property will be removed. This is a bad news for me (and I ...

9 månader ago | 3 answers | 3

Answered

Create coordinates on a convex hull

% test data xy=rand(100,2); P=xy(convhull(xy),:); d=[0;cumsum(sqrt(sum(diff(P).^2,2)))]; xyi=interp1(d,P,linspace(0,d(end)...

Create coordinates on a convex hull

% test data xy=rand(100,2); P=xy(convhull(xy),:); d=[0;cumsum(sqrt(sum(diff(P).^2,2)))]; xyi=interp1(d,P,linspace(0,d(end)...

9 månader ago | 0

| accepted

Answered

How to leave only the elements that appear once per page?

If I understand you correctly % Test data A=rand(2,2,5)>0.7 B = logical(A.*cumprod(cat(3,ones(size(A(:,:,1))),1-A(:,:,1:end...

How to leave only the elements that appear once per page?

If I understand you correctly % Test data A=rand(2,2,5)>0.7 B = logical(A.*cumprod(cat(3,ones(size(A(:,:,1))),1-A(:,:,1:end...

9 månader ago | 1

| accepted

Answered

How to sum the intervals in matlab

I have no idea what is the purpose and what is the problem, juste point out you might try nv = cal.*v.'

How to sum the intervals in matlab

I have no idea what is the purpose and what is the problem, juste point out you might try nv = cal.*v.'

9 månader ago | 0

| accepted

Answered

Specific number of 1s in a 0s - 1s matrix

N=10; d=3; [~,c] = mink(rand(N,N-1),d,2); r = (1:N)'; c(c>=r) = c(c>=r)+1; A = accumarray([repmat(r,[d,1]),c(:)],1,[N N])...

Specific number of 1s in a 0s - 1s matrix

N=10; d=3; [~,c] = mink(rand(N,N-1),d,2); r = (1:N)'; c(c>=r) = c(c>=r)+1; A = accumarray([repmat(r,[d,1]),c(:)],1,[N N])...

9 månader ago | 1

Answered

is it a bug?

No it's not a bug: from PLOT doc If one of X or Y is a scalar and the other is either a scalar or a vector, then the plot funct...

is it a bug?

No it's not a bug: from PLOT doc If one of X or Y is a scalar and the other is either a scalar or a vector, then the plot funct...

9 månader ago | 1

Answered

Removing nested for loops for quicker time

I know totalDistance third dimension is a singleton p, the third dimension imagesList of is 3, and other dimensions of tot...

Removing nested for loops for quicker time

I know totalDistance third dimension is a singleton p, the third dimension imagesList of is 3, and other dimensions of tot...

9 månader ago | 0

Answered

Finding Linear regression equation

P=polyfit(x,y,1); m=P(1), b=P(2), % linefit = polyval(P,x)

Finding Linear regression equation

P=polyfit(x,y,1); m=P(1), b=P(2), % linefit = polyval(P,x)

9 månader ago | 0