Answered
Sum the component of a matrix till a certain value
ix = cumsum(M(:))<80; v = mod(nnz(ix),size(M,1)); [~,c] = ind2sub(size(M),nnz(ix)); Wanted = M(:,1:c-(v~=0))

7 years ago | 0

| accepted

Answered
Create a random array with specified conditions
s = randperm(20,6); % example random generated vector repelem(s,2)

7 years ago | 1

| accepted

Answered
Find rows in matrix based on columns value
ix = sum(ismember(mat,[10,11]),2)==2; row_index = find(ix) edit: row_index = find(sum(~mod(mod(mat,10),11),2)==1)

7 years ago | 2

Answered
how to track location of number in array after sorting?
[~,Wanted] = sort(B,'descend')

7 years ago | 1

| accepted

Answered
Matlab script to add the values of elements
Google search *"for loop sum MATLAB"*

7 years ago | 0

Answered
Problem filtering a table
A = raw(strcmp(raw( : ,2),p),:) % ^

7 years ago | 0

| accepted

Answered
Removing certain rows from B using A as reference to produce C
c = B(ismember(B(:,1),A),:)

7 years ago | 0

| accepted

Answered
Help Plotting Piecewise functions
You are almost there , change *e* to *exp()* syms x y = piecewise(0<=x<=3, 4*x^1/3, 3<x<=6, pi^(x+e)) % Note the par...

7 years ago | 0

Answered
Going from structure to matrix
Why not use *struct2array()* ? Note: Don’t Name a variable named *ans* .

7 years ago | 4

| accepted

Answered
Help with plotting a function
x=linspace(2.75, 3,1000) y=sqrt(sin(x.^2)) % have a look here plot(x,y) title('This is all the things') xlabel('This is the ...

7 years ago | 0

Answered
How to create a vector of elements with a number of row equal to a number?
Honestly I am not able to get you but perhaps you just want: C = repelem(B,20)

7 years ago | 1

| accepted

Answered
How to find out coordinates of a value from a matrix?
c(v==5,:) % same for 0

7 years ago | 0

Answered
Counting the maximum occurrence of an element in 3d matrix ?
sum(3dmatrix==1,[1,2]) % for older versions sum(sum(3dmatrix==1,2),1)

7 years ago | 1

| accepted

Answered
reduce rows of a due to b
ix = ismember(a,b,'rows'); a(ix,:) % gives you the rows in a which is common to b and ~ix vice versa

7 years ago | 0

| accepted

Answered
Extracting elements from a/an vector/array with a specific order
A1(3:3:100) % learn MATLAB's indexing https://in.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html

7 years ago | 0

| accepted

Answered
Plotting all the columns of a matrix
No loops needed: plot(mat) axis([0,5,0,5])

7 years ago | 2

Answered
Not enough input arguments. in ode45
[m,y] = ode45(@vdp1,[0 20],[2; 0]); plot(m,y(:,1),'-o',m,y(:,2),'-o') title('Solution of van der Pol Equation (\mu = 1) with...

7 years ago | 0

| accepted

Answered
Allocate certain numbers to create a new matrix from A and B
c=repmat(1:size(A,2),size(A,1),1); v=(A==1) .* c; vv=cell2mat(arrayfun(@(x) B(x,:),nonzeros(v.'),'un',0)); Rows_of_A=...

7 years ago | 0

| accepted

Answered
Placing a constant through a column
repmat(BB,3,1)

7 years ago | 0

| accepted

Answered
how to remove zero matrix(all elements are zeros) from 'distances which is 3d matrix'??
distances(:,:,squeeze(~all(distances,[1,2])))=[] % if you're using an older version then: distances(:,:,squeeze(~all(all(di...

7 years ago | 0

| accepted

Question


Is there a possibility to use varargin()?
Is there any other way to perform such operation? c = {rand,rand(4)}; z = @(...) mean(...); z(c{:}) The same can be achieved...

7 years ago | 0 answers | 0

0

answers

Answered
Using ODE45 to solve two coupled second order ODEs
syms x1(t) x2(t) k1 k2 m Dx1 = diff(x1); D2x1 = diff(x1,2); Dx2 = diff(x2); D2x2 = diff(x2,2); Eq1 = D2x1 == (-(k1+k2)*x1+...

7 years ago | 1

| accepted

Answered
How to split cell array values into two text file?
v=dlmread('sample.txt') % your file name , use readmatrix() if you’re using 2019a or later dlmwrite('txt1.txt',v(:,1)) ...

7 years ago | 0

| accepted

Answered
Could any body check my work? (Plot the function)
<https://in.mathworks.com/help/matlab/ref/linespec.html?s_tid=doc_ta#f26-701830> Your x and y doesn’t need square brackets. ...

7 years ago | 0

| accepted

Answered
How can i use a cell array in the symbolic variables?
Wanted = num2cell(symvar(B)) edit: After your comment. >> syms a b c d x y z >> A = [ a*(x^2) , b*(y^3) ; d*(x^2)*y , c ] ...

7 years ago | 1

| accepted

Answered
How can we transpose a row vector into column vector in a cell
cellfun(@(x) x(:),A,'un',0)

7 years ago | 0

| accepted

Answered
location of logical matrix
Since you have a logical matrix it’simply: ix=all(matrix ,2); % logical indexing is efficient Wanted=find(ix)

7 years ago | 0

| accepted

Answered
how to use if in matlab for 2 matrix condition?
r=R2; r(abs(R1)<1)=R1

7 years ago | 0

Answered
surface Z contain more than one row or column
x1=0.0001:.001:.01; % you would have to decide the points yourself x2=0.003:0.001:0.08; [X,Y]=meshgrid(x1,x2); rho_ss=8000; ...

7 years ago | 1

Answered
fprintf in if statement
if x == 1 % where x is assumed as a scalar fprintf('hello') end help if doc if

7 years ago | 0

| accepted

Load more