Solved

Capitilize the first letter of every word in a string

For a given input string, capitalize every letter at the beginning of a word, and transform the rest of the letters to lower-cas...

3 Tage ago

Solved

Four quadrant inverse tangent function.

Create a function that returns an array P the same size as X and Y containing the element-by-element, four-quadrant inverse tang...

3 Tage ago

Solved

surface of parallelogram

Given 2 vectors of each 3 elements, determine the surface of the parallelogram which can be created from these 2 vectors.

3 Tage ago

Solved

Generalized Fibonacci

The Fibonacci sequence is defined as: Fib(1) = 0 Fib(2) = 1 Fib(N) = Fib(N-1) + Fib(N-2) The Fibonacci sequence ca...

3 Tage ago

Answered

How can I use arrayfun and integral as anonymous function?

I am doing a little guessing. I assume you want to integrate with respect to s (0,t) then look at t from 0:0.1:1. syms s t v=0...

How can I use arrayfun and integral as anonymous function?

I am doing a little guessing. I assume you want to integrate with respect to s (0,t) then look at t from 0:0.1:1. syms s t v=0...

3 Tage ago | 1

Answered

Solve Nonlinear complex equation

syms c1 c2 c3 c4 c5 c6 x1 x2; eqn=c1*exp(1i*x1)+c2*exp(1i*c3)-c4*exp(1i*c5)+x2*exp(1i*c6)==0; a=solve(eqn,x1); b=solve(eqn,x2...

Solve Nonlinear complex equation

syms c1 c2 c3 c4 c5 c6 x1 x2; eqn=c1*exp(1i*x1)+c2*exp(1i*c3)-c4*exp(1i*c5)+x2*exp(1i*c6)==0; a=solve(eqn,x1); b=solve(eqn,x2...

4 Tage ago | 0

Answered

Could someone please explain what is wrong in my function?

Why not just use built-in function sign()? a=sign(A); %then index into a for specific element

Could someone please explain what is wrong in my function?

Why not just use built-in function sign()? a=sign(A); %then index into a for specific element

4 Tage ago | 2

Answered

How to sum specific elements of a matrix

m=randi(100,6);%your assumed matrix m=[m;mean(m([1 4],:));mean(m([2 5],:));mean(m([3 6],:))]; b=[mean(m(:,[1 4]),2),mean(m(:,[...

How to sum specific elements of a matrix

m=randi(100,6);%your assumed matrix m=[m;mean(m([1 4],:));mean(m([2 5],:));mean(m([3 6],:))]; b=[mean(m(:,[1 4]),2),mean(m(:,[...

4 Tage ago | 0

Answered

How do I correct the error "Matrix dimensions must agree"?

Your problem is with the norm() function. You cannot subtract at 4x1 vector from a 5x1. Maybe you ment: for i=1:length(k), e(i)...

How do I correct the error "Matrix dimensions must agree"?

Your problem is with the norm() function. You cannot subtract at 4x1 vector from a 5x1. Maybe you ment: for i=1:length(k), e(i)...

5 Tage ago | 0

| accepted

Answered

Initializing 1/2 of a row with one value and the other half with another

You are concatenating two arrays. Look at the ones() and zeros() functions. a=ones(1,5); b=zeros(1,6); c=[a,b];

Initializing 1/2 of a row with one value and the other half with another

You are concatenating two arrays. Look at the ones() and zeros() functions. a=ones(1,5); b=zeros(1,6); c=[a,b];

5 Tage ago | 0

| accepted

Answered

Find the indices of the imaginary element of the matrix

Lidx=find(imag(A)~=0);

Find the indices of the imaginary element of the matrix

Lidx=find(imag(A)~=0);

5 Tage ago | 0

| accepted

Answered

How to make the code efficient?

n=10; [x,y]=meshgrid(0:n-1); idx=mod(y.^2-x.^3-2*x-3,n)==0; xy_mtx=[x(idx),y(idx)];

How to make the code efficient?

n=10; [x,y]=meshgrid(0:n-1); idx=mod(y.^2-x.^3-2*x-3,n)==0; xy_mtx=[x(idx),y(idx)];

5 Tage ago | 1

Answered

How do i create a table with increments of occurrences of a value based on another column?

x= [1,2,3,4,5,1,3,4,6,5,1,3]; y=unique(x); z=ones(size(x)); for k=y a=find(x==k); z(a)=1:length(a); end

How do i create a table with increments of occurrences of a value based on another column?

x= [1,2,3,4,5,1,3,4,6,5,1,3]; y=unique(x); z=ones(size(x)); for k=y a=find(x==k); z(a)=1:length(a); end

5 Tage ago | 0

Answered

Create an string array with strings having both char and numbers

k=[]; for n=1:25; k=[k,string(sprintf('Analysis_%d',n))]; end

Create an string array with strings having both char and numbers

k=[]; for n=1:25; k=[k,string(sprintf('Analysis_%d',n))]; end

5 Tage ago | 1

| accepted

Answered

Indexing vectors in a cell matrix with for loops?

newmat=zeros(1500,8) for k=1:8 t=yourCell{k}(1:3,:); t=t'; newmat(:,k)=t(:); end

Indexing vectors in a cell matrix with for loops?

newmat=zeros(1500,8) for k=1:8 t=yourCell{k}(1:3,:); t=t'; newmat(:,k)=t(:); end

6 Tage ago | 0

Solved

Generate a vector which contains a pyramid pattern (★★★★)

Generate a vector that contains terms that follows a pyramid pattern up to the nth row: 1 2 2 3 3 3 4 4 4 4 ...

6 Tage ago

Solved

Extract leading non-zero digit (★★★★★)

(Copy of Problem 47) Benford's Law states that the distribution of leading digits is not random. This is probably because man...

6 Tage ago

Solved

Matrix Indexing

Given a matrix A and scalars r,c,i, find the product of two elements, with the first element located at row r and column c (doub...

6 Tage ago

Solved

Matrix convolution

A certain convolution step involves an elementwise multipication between two 3x3 matrices and taking the resulting sum of the el...

6 Tage ago

Solved

Stacking vectors into a matrix

Given a 4x1 vector a, and a 2x2 matrix b, create a matrix M in which the first 2 rows are each identical to a and the last two r...

6 Tage ago

Solved

Logarithmically spaced vector creation using linspace

Create a vector y containing n logarithmically spaced values between a and b, with a < b. Avoid using logspace and use the linsp...

6 Tage ago

Solved

Logarithmically spaced vector creation using logspace

Create a vector y containing n logarithmically spaced values between a and b, with a < b. Use the logspace operator.

6 Tage ago

Solved

Vector creation using colon operator

Create a vector y containing n uniformly spaced values between a and b, with a < b. Use the colon (:) operator.

6 Tage ago

Answered

How do I add values of a function to a matrix?

nada=zeros(64); for a=1:64 for b=1:64 nada(a,b)=delta(a,b); end end

How do I add values of a function to a matrix?

nada=zeros(64); for a=1:64 for b=1:64 nada(a,b)=delta(a,b); end end

6 Tage ago | 0

Solved

Make a checkerboard matrix (★★★★★)

(copy of Prob. 4) Given an integer n, make an n-by-n matrix made up of alternating ones and zeros as shown below. The a(1...

7 Tage ago

Solved

Vector creation using linspace

Create a vector y containing n uniformly spaced values between a and b, with a < b. Use linspace.

7 Tage ago

Solved

Determine the average number of rounds for the following game.

Each round a uniformly distributed random number is picked between 0 and 1. The game ends when the sum of the random numbers is ...

8 Tage ago

Solved

Compute a sum of Ramanujan

Srinivasa Ramanujan defined the following function: Write a function to compute for various values of . See also Cody Proble...

8 Tage ago

Solved

Right shift an array n times with constant space.

Right shift an array n times with constant space, that is, no extra array can be used. Right shift operation: Last element com...

8 Tage ago