Solved


Calculate mean value of any pair in a vector.
Given a vector A, calculate the mean of 2 number in the vector one by one. example: input: A=[1, 5, 6, 8, 9, 15] output:...

5 years ago

Solved


Find all repeated numbers
For a given vector, find all numbers that repeated 2 times or more than 2 times. Example: A=[1 2 3 3 4 5 6 6 7] y=[3 ...

5 years ago

Solved


Prime numbers between a , b.
Find all prime number between a & b (including a and b). example: a=100 b=120 y= [101 103 107 109 113]

5 years ago

Solved


Draw 'O' !
Given n as input, generate a n-by-n matrix 'O' using 0 and 1 . example: n=4 ans= [1 1 1 1 1 0 0 1 ...

5 years ago

Solved


Draw 'C'.
Given x as input, generate a x-by-x matrix 'C' using 0 and 1. example: x=4 ans= [0 1 1 1 1 0 0 0 ...

5 years ago

Solved


Draw 'F'
Draw a x-by-x matrix 'F' using 1 and 0. (x is odd and bigger than 4) Example: x=5 ans= [1 1 1 1 1 1 0 0 0 0 ...

5 years ago

Solved


Draw 'D'.
Draw a x-by-x matrix 'D' using 0 and 1. example: x=4 ans= [1 1 1 0 1 0 0 1 1 0 0 1 1 1 1 0]

5 years ago

Solved


Draw a 'N'!
Given n as input, generate a n-by-n matrix 'N' using 0 and 1 . Example: n=5 ans= [1 0 0 0 1 1 1 0 0 1 1 0 ...

5 years ago

Solved


Draw 'E'
Draw a x-by-x matrix 'E' using 1 and 0. (x is odd and bigger than 4) Example: x=5 ans= [1 1 1 1 1 1 0 0 0 0 ...

5 years ago

Solved


Draw a 'Z'.
Given _n_ as input, generate a n-by-n matrix like 'Z' by _0_ and _1_ . Example: n=5 ans= [1 1 1 1 1 0 0 0 1 ...

5 years ago

Solved


Draw 'B'
Draw a x-by-x matrix 'B' using 1 and 0. (x is odd and bigger than 4) Example: x=5 ans= [1 1 1 1 0 1 0 0 0 1 ...

5 years ago

Solved


Draw 'J'
Given n as input, generate a n-by-n matrix 'J' using 0 and 1 . Example: n=5 ans= [0 0 0 0 1 0 0 0 0 1 0 0 ...

5 years ago

Solved


Draw 'H'
Draw a x-by-x matrix 'H' using 1 and 0. (x is odd and bigger than 2) Example: x=5 ans= [1 0 0 0 1 1 0 0 0 1 ...

5 years ago

Answered
How to generate the sum of a random number ?
n = randn; x = 0; while x <= 9 n = randn;%needs to be in the loop if n > 3 fprintf('The random number is gr...

5 years ago | 0

| accepted

Answered
Plotting a function within for loop
function RetractionModel2 AB = 0.0732; AD = 0.0788; BC = 0.0585; CD = 0.0575; a0 = 99.4; for i= 0:90 alpha = a0 -...

5 years ago | 1

| accepted

Answered
how to get all max values of one vector
m=X(ismember(X,max(X)));

5 years ago | 0

| accepted

Answered
How to index in for loop
for k=1:length(a) c(:,:,k)=a(k)*b;%index instead of having different variables d(:,:,k)=r-c(:,:,k)*x; end

5 years ago | 0

| accepted

Answered
Repeating a function for different values and storing the output in different variables.
for k=1:10%however many times you want to run it P{k}=points_on_plane(p0,p1,p2);%just use a cell array for your output so tha...

5 years ago | 0

| accepted

Answered
How to plot the figure with 3 variables in 2d, with the value of z is proportional to the color?
m=min(Detal_E); M=max(Detal_E); c=(Detal_E-m)/(M-m)*9+1; scatter(X,Y,25,c,'filled');

5 years ago | 0

| accepted

Answered
"Index exceeds the number of array elements" Spring Mass Damper System
for i=1:N t(i+1) = t(i)+h; x(i+1) = x(i)+h*(v(i)); v(i+1) = v(i)+h*(u(i)-(c/m)*v(i)-(k/m)*x(i));%appears your problem i...

5 years ago | 1

| accepted

Answered
Convert plot to 64 by 64 grid matrix
[x,y]=meshgrid(linspace(-2,2,64)); z=zeros(size(x)); k=x.^2+y.^2; z(k<=1)=1;%z is the grid matrix

5 years ago | 0

Answered
Index exceeds the number of array elements in a while loop
No need for any loops. No need for symbolics. h = linspace (7620,11000,169); D = 288.19-0.00649.*h; rho= 1.225*(D/288.19).^(...

5 years ago | 1

| accepted

Solved


Dudeney Numbers: Numbers which are the cube of their decimal sum
From Wikipedia: _A Dudeney number is a positive integer that is a perfect cube such that the sum of its decimal digits is equa...

5 years ago

Answered
Sequentially load images and generates textures with corresponding names
Why not use cell array? for k=1:40 s=num2str(k); if length(s)==1 s=['0',s]; end texture{k}=Screen('Maketextur...

5 years ago | 0

| accepted

Answered
How to display a percent sign (%) using latex and sprintf
sprintf('New percent OS = %s%.2f','%',percentOS);

5 years ago | 0

Answered
using logical functions to display arrays
P =[12 7.95 88 26.5 27.9 3.5 57 65.9 17.7 35.6 15 96.5 ]; discountedPrice=zeros(size(P)); discountedPrice(P<10)=P(P<10)*.95; ...

5 years ago | 1

| accepted

Answered
Saving figure as a image
You might try figure2pdf in file exchange. https://www.mathworks.com/matlabcentral/fileexchange/71053-figure2pdf?s_tid=srchtitl...

5 years ago | 0

Answered
Re-arranging row of a matrix in array.
[A,b]=sort(A); B=B(b);

5 years ago | 0

Answered
Sort a table with different orders for different columns
You can't have a matrix with characters and numbers. But if you convert the characters to double, then: A=[sort(A(:,1)),sort(A(...

5 years ago | 0

Load more