Answered

problem with fzero in my code

your fun is neither acceppting nor using inputs You should write the symbolic function like this fun = @(x)cos(x); x0 = fzero...

problem with fzero in my code

your fun is neither acceppting nor using inputs You should write the symbolic function like this fun = @(x)cos(x); x0 = fzero...

5 hours ago | 0

Answered

how can i slove this proplem "- The vector V is given by V=[2 8 7 3 1 0 8 9]. Write down a single instruction to produce a vector that contains 1 in the place of the odd numbers and -1 in the place of the even numbers."

A suggestion: you can easily find the reminder of the division by 2, so that even numers have reminder 0 and odd numbers reminde...

how can i slove this proplem "- The vector V is given by V=[2 8 7 3 1 0 8 9]. Write down a single instruction to produce a vector that contains 1 in the place of the odd numbers and -1 in the place of the even numbers."

A suggestion: you can easily find the reminder of the division by 2, so that even numers have reminder 0 and odd numbers reminde...

19 hours ago | 0

Answered

Operands to the || and && operators must be convertible to logical scalar values.

If you work with arrays, use the single & and not &&

Operands to the || and && operators must be convertible to logical scalar values.

If you work with arrays, use the single & and not &&

20 hours ago | 0

Answered

How to use fzero in a loop to obtain the first 3 positve solutions for cos3x=sin3x?

fzero gives you only one solution. In case of multiple roots, the choice depends on the initial choice and on the algorithm. If ...

How to use fzero in a loop to obtain the first 3 positve solutions for cos3x=sin3x?

fzero gives you only one solution. In case of multiple roots, the choice depends on the initial choice and on the algorithm. If ...

20 hours ago | 0

Answered

how to write a code to extract a positive latitude value for the corresponding positive longitudinal cell value

% filter idx = longitudinal >= 50 & longitudinal <= 100 & latitude >= 0 & latitude <= 40; % selection longitudinal2 = longi...

how to write a code to extract a positive latitude value for the corresponding positive longitudinal cell value

% filter idx = longitudinal >= 50 & longitudinal <= 100 & latitude >= 0 & latitude <= 40; % selection longitudinal2 = longi...

22 hours ago | 0

Answered

Making a vector out of all even and odd numbers using for, if

This happens because the original vector contains random numbers that change every time you run the code. So, also the number of...

Making a vector out of all even and odd numbers using for, if

This happens because the original vector contains random numbers that change every time you run the code. So, also the number of...

22 hours ago | 0

Answered

Error using plot Vectors must be the same length.

Some comments 1) Q is defined twice as symbolic variable, but it is actually an array 2) in the first loop N = 4, so length(t)...

Error using plot Vectors must be the same length.

Some comments 1) Q is defined twice as symbolic variable, but it is actually an array 2) in the first loop N = 4, so length(t)...

2 days ago | 0

| accepted

Answered

Optimisation of function containing matrix

While waiting for the data, I try to solve one of the questions. you can set the missing constraint as x1-x2 = 0 x2-x3 = 0 .....

Optimisation of function containing matrix

While waiting for the data, I try to solve one of the questions. you can set the missing constraint as x1-x2 = 0 x2-x3 = 0 .....

3 days ago | 0

| accepted

Answered

How to plot points on a line

I suggest you to check hold on, and the LineSpec of the command plot % your data new = rand(5,1); % open figure and retain ...

How to plot points on a line

I suggest you to check hold on, and the LineSpec of the command plot % your data new = rand(5,1); % open figure and retain ...

4 days ago | 1

| accepted

Answered

How to break an image into blocks?

Three assumprions 1) the image is a 2d matrix 2) the row/cols have 64x3, 3x64 and 3x3 blocks 3) you want 10 sub images, not 1...

How to break an image into blocks?

Three assumprions 1) the image is a 2d matrix 2) the row/cols have 64x3, 3x64 and 3x3 blocks 3) you want 10 sub images, not 1...

4 days ago | 0

Answered

Optimization problem using external program

I can figure out two solutions 1) check if the simulation program has API for running it from "outside". In this case, make ref...

Optimization problem using external program

I can figure out two solutions 1) check if the simulation program has API for running it from "outside". In this case, make ref...

4 days ago | 0

| accepted

Answered

Intersections between 2 graphs

Try this software on fex https://it.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections

Intersections between 2 graphs

Try this software on fex https://it.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections

4 days ago | 0

| accepted

Answered

Adjusting the resolution of the time vector

Try pdeval and supply the solution of pdepe

Adjusting the resolution of the time vector

Try pdeval and supply the solution of pdepe

5 days ago | 0

Answered

Why my integration is like this?

You are calulating an indefinte integral that has an integration constant by definition. Matlab int command doesn't add the inte...

Why my integration is like this?

You are calulating an indefinte integral that has an integration constant by definition. Matlab int command doesn't add the inte...

5 days ago | 0

Answered

Calculate the angle between plane normal and a point it cuts

using the definition of dot product: % angle function in radians ang = @(u,v)acos(dot(u,v)/(norm(u)*norm(v))); % data u = ...

Calculate the angle between plane normal and a point it cuts

using the definition of dot product: % angle function in radians ang = @(u,v)acos(dot(u,v)/(norm(u)*norm(v))); % data u = ...

5 days ago | 0

Answered

How to obtain the original matrix after performing symrcm or symamd in MATLAB?

Can you share the symV original matrix?

How to obtain the original matrix after performing symrcm or symamd in MATLAB?

Can you share the symV original matrix?

5 days ago | 0

| accepted

Answered

Create an array from other array

x = [-V(:) -M(:)]; The column operator here reshapes the vector into a column vector

Create an array from other array

x = [-V(:) -M(:)]; The column operator here reshapes the vector into a column vector

6 days ago | 0

| accepted

Answered

Cumalative sum of each row of the matrix and the matrix array, separately

For the matrix Msum = cumsum(M,2) For the cell array Gsum = cellfun(@cumsum,G,'UniformOutput',false)

Cumalative sum of each row of the matrix and the matrix array, separately

For the matrix Msum = cumsum(M,2) For the cell array Gsum = cellfun(@cumsum,G,'UniformOutput',false)

6 days ago | 2

| accepted

Answered

counting the number of clusters

% unique indices idx = unique(data(:,1)); % clusters cluster = arrayfun(@(idx)data(data(:,1) == idx,2),idx,'UniformOutput'...

counting the number of clusters

% unique indices idx = unique(data(:,1)); % clusters cluster = arrayfun(@(idx)data(data(:,1) == idx,2),idx,'UniformOutput'...

6 days ago | 0

| accepted

Answered

How to extract numbers with its corresponding numbers in the next column from a file?

Does this solve your question? % complete data UD = load('APP_C20_1_Press_Unfiltered.txt'); DataGreaterThan1000 = UD(UD(:...

How to extract numbers with its corresponding numbers in the next column from a file?

Does this solve your question? % complete data UD = load('APP_C20_1_Press_Unfiltered.txt'); DataGreaterThan1000 = UD(UD(:...

6 days ago | 1

Answered

How to write a for loop that indexes the variable name and the funciton?

Don't do that! Check this out: https://it.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-...

How to write a for loop that indexes the variable name and the funciton?

Don't do that! Check this out: https://it.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-...

6 days ago | 1

| accepted

Answered

How to obtain the original matrix after performing symrcm or symamd in MATLAB?

Try this: % matrix dimensions N = 5; % create symmetric matrix A = rand(N); A = A+A.'; % symrcm sorting p = symrcm(A)...

How to obtain the original matrix after performing symrcm or symamd in MATLAB?

Try this: % matrix dimensions N = 5; % create symmetric matrix A = rand(N); A = A+A.'; % symrcm sorting p = symrcm(A)...

6 days ago | 0

Answered

Trying to recreates the center of mass from equation

Macroscopically, I see two main issues 1) third line [n,-] = size(qDat); should be (tilde sign) [n,~] = size(qDat); 2) last...

Trying to recreates the center of mass from equation

Macroscopically, I see two main issues 1) third line [n,-] = size(qDat); should be (tilde sign) [n,~] = size(qDat); 2) last...

6 days ago | 0

Answered

how to fill a matrix?

If I understand correctly % number of measurements med = 8; % preallocation VecVal = zeros(1,med); % the measurement X...

how to fill a matrix?

If I understand correctly % number of measurements med = 8; % preallocation VecVal = zeros(1,med); % the measurement X...

6 days ago | 0

| accepted

Answered

Function with two inputs and arguments

The & is misused. Try: function [xp,xm] = find_roots(a,b,c) if b^2-4*a*c<0 xp=888; xm=888; else xp=(-b/(2*a))+...

Function with two inputs and arguments

The & is misused. Try: function [xp,xm] = find_roots(a,b,c) if b^2-4*a*c<0 xp=888; xm=888; else xp=(-b/(2*a))+...

6 days ago | 1

| accepted

Answered

Creating Random Coordinates Inside a Fixed Points

% geometry data xMax = 12; yMax = 8; rCircle = 2; % number of points N = 1000; % points iside the rectangle P = bsxfu...

Creating Random Coordinates Inside a Fixed Points

% geometry data xMax = 12; yMax = 8; rCircle = 2; % number of points N = 1000; % points iside the rectangle P = bsxfu...

17 days ago | 2

| accepted

Answered

I want to Plot a triangle using points p, q ,and r. Also, I need to show vectors PQ and PR starting from p and their cross product vector V

Replace the first plot with % plot vertices plot3([p(1); q(1); r(1); p(1)],[p(2); q(2); r(2); p(2)],[p(3); q(3); r(3); p(3)],...

I want to Plot a triangle using points p, q ,and r. Also, I need to show vectors PQ and PR starting from p and their cross product vector V

Replace the first plot with % plot vertices plot3([p(1); q(1); r(1); p(1)],[p(2); q(2); r(2); p(2)],[p(3); q(3); r(3); p(3)],...

17 days ago | 0

Answered

How do I make matrix of ones and zeros alternating depending on size and elements of an array?

% initialize iRow = []; jCol = []; % preallocate B = zeros((length(A)+1)/2,sum(A)); % indices for columns idx = [0; ...

How do I make matrix of ones and zeros alternating depending on size and elements of an array?

% initialize iRow = []; jCol = []; % preallocate B = zeros((length(A)+1)/2,sum(A)); % indices for columns idx = [0; ...

18 days ago | 1

| accepted

Answered

I want to Plot a triangle using points p, q ,and r. Also, I need to show vectors PQ and PR starting from p and their cross product vector V

p = [15,20,14]; q = [19,21,9]; r = [16,19,11]; % open figure and setup view figure, hold on view([1 1 1]); % plot vert...

I want to Plot a triangle using points p, q ,and r. Also, I need to show vectors PQ and PR starting from p and their cross product vector V

p = [15,20,14]; q = [19,21,9]; r = [16,19,11]; % open figure and setup view figure, hold on view([1 1 1]); % plot vert...

18 days ago | 1

Answered

How to extract values from a field of a stucture?

I don't have the data so I cannot test it. Try % select the Scenario iScenario = 1; % plot surf(Dati.X,Dati.Y,Dati.Val(iSc...

How to extract values from a field of a stucture?

I don't have the data so I cannot test it. Try % select the Scenario iScenario = 1; % plot surf(Dati.X,Dati.Y,Dati.Val(iSc...

18 days ago | 1

| accepted