Answered
count of non zero elements of a row vector in a loop
Read about nnz.

6 years ago | 0

Answered
How to print all prime numbers between 1 and 100 using a for loop?
num = 1:100 ; % numbers till 100 idx = isprime(num) ; % get logical indices of prime numebrs num(idx) % print the prime ...

6 years ago | 1

| accepted

Answered
Accepting and rejecting values in numeric array
A = randi(10,10,2) ; % random data for demo % Remove values greater than 8 in column 1 idx = A(:,1)>8 ; % get indices of...

6 years ago | 0

Answered
JPEG Image Compression with a for loop
Refer this: https://in.mathworks.com/matlabcentral/answers/399622-resizing-images-using-interp1

6 years ago | 0

Answered
Finding distance between values in a column vector
dPeakTime = diff(PeakTime) ; % get the difference between consecutive PEak times AvgPeakDistance = sum(dPeakTime)/numel(dPeakT...

6 years ago | 0

| accepted

Answered
Interpolate NaN on graph
Read about fillmissing. https://in.mathworks.com/help/matlab/ref/fillmissing.html

6 years ago | 0

Answered
How to efficiently match the zeros of 1 matrix with another
If D and S are your matrices of size 26*12*160. To repalce zeros in S where D is zero, simply use: idx = D ==0 ; % get indices...

6 years ago | 0

| accepted

Answered
How to modify the code below so it can loop over certain files rather then 1?
csvFiles = dir("*.csv") ; N = length(csvFiles) ; C = zeros(N,3) ; for i = 1:N XY = dlmread(csvFiles(i).name); [x...

6 years ago | 1

| accepted

Answered
want to read 38 csv files only first and second column?
csvFiles = dir("*.csv") ; N = length(csvFiles) ; for i = 1:N data = csvread(csvFiles(i).name) ; % also read about xlsre...

6 years ago | 0

Answered
How i can solve the this second order diffrential equation
syms y(x) c w Dy = diff(y,x) ; D2y = diff(Dy,x) ; ode = D2y-(3+2*w)*cot(x)*Dy-2*(1+w)*y==(16/3)*w*(c^2)*(cos(x)^2)+(16/...

6 years ago | 1

Answered
plotting map from a matrix
You can use pcolor. Read about it. Also have a look on surf. You can have a look on this package: https://www.eoas.ubc.ca/~ric...

6 years ago | 0

Answered
How can I get the secondary diagonal of a matrix?
Read about diag. You can get diagonal elements by using that. A = rand(5) ; diag(A) diag(A,-1) diag(A,1) May be you are lo...

6 years ago | 0

Answered
Different assignment of coordinates in meshgrid().
Let A be your 3D matrix. [m,n,p] = size(A) ; [X,Y,Z] = meshgrid(1:p,1:n,1:m) ;

6 years ago | 0

Answered
How can I create unique rows in a matrix?
A = [ 0 0 0 3 6 6 4 5 6 4 6 5 5 4 6 5 5 5 5 ...

6 years ago | 0

Answered
Figure does not display graph
Replace the lines: plot(x,y,'red') with plot(x,y,'color','red') Make these changes: plot(torque, W,'color', 'blue') %angu...

6 years ago | 1

| accepted

Answered
how to create a 3d plot for this matrix
Read about spy. A = randi(10,10) ; A(A>1) = 0 ; spy(A)

6 years ago | 0

Answered
How to split sentence?
s = strsplit(cover_str,'.')

6 years ago | 0

| accepted

Answered
Error: Unable to perform assignment because the left and right sides have a different number of elements.
This line: y(j)=x(j)+sigma*randn(size(j)); will create error..because, you are trying to save more number of elements then it...

6 years ago | 0

Answered
Making the assumption to be the same as results
ro_init=0.2:0.1:100; r = 200 ; c = 200 ; % Try increasing these values B = linspace(0,0.1,r) ; N = linspace(0.8,2,c) ; [B...

6 years ago | 0

| accepted

Answered
Selective summary of matrix array
Read about cumsum. https://in.mathworks.com/help/matlab/re f/cumsum.html iwant = cumsum(A) ;

6 years ago | 1

| accepted

Answered
Confusion about elseif statements
The function is fine...there is one typo error..... you should use '=' not '==' function output = findtype(input); [r c] = si...

6 years ago | 0

Answered
How to find which curve fit best to another curve
To fit a polynomial read about polyfit. For curve fetting read about cftool, fit. To comapre the two curves..use the differenc...

6 years ago | 1

Answered
how to write name on plotted graph?
Read about legend. p=[123 456 344 333 667 899 565 546 688 998 765 467] T=[30 45 55 66 77 54 32 34 25 70 12 34] m=[1.00 2.00 2...

6 years ago | 0

Answered
How do I allocate one point only in matrix A to its closest point in matrix B
Read about knnsearch. This function will give you the number points you specified which are close. https://in.mathworks.com/he...

6 years ago | 0

Answered
Finding the maximum of a vector using only for loop and the routine length
v = [ 1 5 6 23 43 5 2 5 2 23 53 45 6 3 4] ; n = length(v) ; themax = 0 ; pos = 1 ; for i = 1:n if v(i)> themax ...

6 years ago | 0

Answered
Function function/ passing function/ varargin help?
a = 8 ; b = 0.25 ; c = 2 ; n = 180 ; f = @(t) a*exp(-b*t).*sin(t-c); t = linspace(a,b,n); y = f(t); fdiff = ma...

6 years ago | 0

Answered
How to use previous points calculated from a function.
You can solve the given equation: R = d2*(t2-t1)/(d1-d2) ; for d2 and solve it to get d2. We have d2 as: d2 = R*d1/(R-t1+t2) ...

6 years ago | 0

Answered
How to solve a set of equations with a vector as input
n = 1000 ; P = linspace(0,50,n) ; wm = (P./k).^(1/3); ws = wm / (-1.008); Ir = sqrt(P/(-0.567); % this will be com...

6 years ago | 1

| accepted

Answered
In Matlab, after plotting a figure then I select a range of area and replot again
Yes you can very much do it.... If you have limits/ range for x-axis; you can limit your range in the existing plot using xlim,...

6 years ago | 0

| accepted

Answered
y'=1-(y/x), y(2)=-1, change in x =0.5. Im supposed to use Euler method to solve this differential equation but I'm not getting the answer I want. I have the code but I'm not sure if I'm doing it right.
Your x value is not correct: You need to check this line: x = 2:h:1.5; % the range of x In the above you need to make changes....

6 years ago | 0

Load more