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

6 years 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(:...

6 years 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-...

6 years ago | 3

| 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)...

6 years 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...

6 years 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...

6 years 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))+...

6 years 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...

6 years 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)],...

6 years 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; ...

6 years 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...

6 years 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...

6 years ago | 1

| accepted

Answered
Selecting specific values from an array based on a defined condition
d+m is not scalar: use a single & for logical AND d(d+m >= 0 & d+m <= 300)

6 years ago | 1

| accepted

Answered
How to visualise 10000 cell volume
Load nodes and faces in a unique structure and plot all patches in a single command tic nodes = []; faces = []; for i = 1:len...

6 years ago | 0

| accepted

Answered
Change specific values in odd/even columns of a matrix
% find all values [iRow,jCol] = find(A == 1); % find odd rows iOdd = rem(jCol,2) ~= 0 % fix values A(sub2ind(size(A),iR...

6 years ago | 1

Answered
How to write a code to solve an equation?
As James Tursa said, the question lacks of information. If it is a homework, I guess you should implement your own algorithm to ...

6 years ago | 1

Answered
Convert 3D coordinates to stl surface
I don't know where the stlPlot function comes from, so I cannot replicate your problem. Anyway, your call tri = delaunay(X,Y,Z)...

6 years ago | 1

Answered
How to integrate this function correctly?
I don't see nothing wrong in the result you get. The result is correct also "'by looking" at time-y_sigma graph. My guesses: Ar...

6 years ago | 0

| accepted

Answered
How to draw circle in a 3D space?
The solution requires the definition of a rotation matrix. There are several ways to use it. Matlab has the rotx, roty and rotz ...

6 years ago | 0

| accepted

Answered
Setting options in fmincon
TolFun is to be used with optimset. With optimoptions use OptimalityTolerance opts = optimoptions('fmincon','OptimalityToleranc...

6 years ago | 0

Answered
How to filter out single/double zero's ?
% find indices idx1 = strfind([0 A == 0 0],[0 1 0]); idx2 = strfind([0 A == 0 0],[0 1 1 0]); % replace A(idx1) = 1; A([id...

6 years ago | 0

| accepted

Solved


Volume of a Parallelepiped
Calculate the volume of a Parallelepiped given the vectors for three edges that meet at one vertex. A cube is a special case ...

6 years ago

Solved


Angle between two vectors
You have two vectors , determine the angle between these two vectors For example: u = [0 0 1]; v = [1 0 0]; The a...

6 years ago

Solved


Make the vector [1 2 3 4 5 6 7 8 9 10]
In MATLAB, you create a vector by enclosing the elements in square brackets like so: x = [1 2 3 4] Commas are optional, s...

6 years ago

Answered
simple linear programming problem
% your code f = [5 -7 -4 6] A = [2 6 1 -1 5 3 -6 -2 -1 -3 6 2] B = [5 7 6] % add lowerbound (0) and upper bound ...

6 years ago | 2

| accepted

Solved


Counting in Finnish
Sort a vector of single digit whole numbers alphabetically by their name, in Finnish. See the Wikipedia page for <http://en.wik...

6 years ago

Solved


Triangle Numbers
Triangle numbers are the sums of successive integers. So 6 is a triangle number because 6 = 1 + 2 + 3 which can be displa...

6 years ago

Answered
How to change a certain array cell depending on its length
mask = strlength(A) > 250; A(mask) = cellfun(@(i) '', A(mask), 'uniform', 0); using a strategy similar to the solution used he...

6 years ago | 0

Answered
how to solve matrix?
If I understand correctly if nnz(M)< T the matrix is the null matrix M = [1 0 1; 0 0 1; 1 1 1]; T = 5; if nnz(M)>= T ...

6 years ago | 0

Answered
how to solve Index exceeds the number of array elements (1).
When i = 2 and inside the loop you have f(1)= -(a*ta) * u_numerical(1); I guess it should be f(i)= -(a*ta) * u_numerical(1); ...

6 years ago | 0

Load more