Community Profile

# David Hill

##### Last seen: Today
1,182 total contributions since 2017

#### David Hill's Badges

View all

Contributions in
View by

help clarifying why code isn't working
fprintf('%15.4f %15.4f %15.4f %15.4f\n',M(1,:),M(2,:),M(3,:),M(4,:));

5 hours ago | 0

| accepted

converting a vector to matrix
Not sure if this is what you are after, but it could be a starting point. Not sure what you mean by ruler lines above and below....

6 hours ago | 0

| accepted

undefined function inside two if statements
Do not know what you want when you say if RoundedBoverT == 2 ... if nnz(RoundedBoverT == 2)%do you mean any element of matrix =...

10 hours ago | 0

Search the given index of a column and then replace the entire column with a single value.
Not sure if this is what you want. [~,col]=ind2sub(size(Data),QI); Data(:,col)=repmat(Mid,1,length(col));

12 hours ago | 0

Could anyone help to covert the equation into matlab code
Not sure what arrays p and g should be. B=sum(log(1+(p(2:n).*g(2:n))./(1+arrayfun(@(x)sum(x*g(3:n)),p(2:n))))/log(2));

13 hours ago | 1

| accepted

Solved

What's the missing interior angle?
I'm talking about polygons... The sum of the interior angles of a triangle is 180 degrees. The sum of the interior angles of a...

16 hours ago

How to compare pair of rows in a column and report it in hexadecimal format
Try this: x=reshape(mymatrix,2,[])'; y=num2str(x(:,1)>x(:,2))'; y=dec2hex(bin2dec(reshape(y(y~=' '),8,[])'))'; hexRep=y(:)';...

1 day ago | 1

| accepted

Solved

Find the maximum two numbers of every column of a matrix
Find the maximum two numbers of every column of a matrix. Example: If we input a matrix A = [ 1 2 4 6 0 3 ...

1 day ago

Plotting 3 graphs in the same figure
z=@(x)x.*sin(pi*(9*x+1)); x={-1:.2:1,-1:.1:1,-1:.01:1}; y=cellfun(@(k)z(k),x,'UniformOutput',false); plot(x{1},y{1},x{2},y{2}...

1 day ago | 0

reshape a char array
reshape(ex,[3,7])'; First number is row and second is column. Matrix is numbered down first.

1 day ago | 0

| accepted

logarithmic scale on MATLAB
semilogx();

1 day ago | 0

Solved

Do they touch?
The center and radius of two circles are given. Determine whether they touch.

1 day ago

How to insert a column in a cell array
Cell arrays can contain anything in there cells. Inserting a empty holder for a column vector: b={a{1:2},[],a{3:end}}

1 day ago | 1

| accepted

How can i plot this function in matlab
You could do something like this: p=1:2:100000; A=1; T=2; f=@(t)A/2 +2*A/pi*sum(sin(p*2*pi*t/T)./p); t=0:.1:2; for k=1:len...

2 days ago | 0

Splitting a matrix into 2 sub matrices based on row number
y=M([1 4 7 8 9 10],:); z=M([2 3 5 6],:);

2 days ago | 0

| accepted

Newton Ralpson on matlab
You could try something like this: function root = newtonR(f,fp,tol) for k=1:3 x=input('root guess'); if ~isinf(1/fp...

2 days ago | 0

Solved

Connect Four - 01
Connect four is a two player board game. <https://en.wikipedia.org/wiki/Connect_Four> Given a complete connect-four board,...

3 days ago

Solved

Connect Four - 02
Previous Problem <https://www.mathworks.com/matlabcentral/cody/problems/45354-connect-four-01> In addition to previous proble...

3 days ago

how can I get successive maximum value from this code?
Why not index B and x? Otherwise, you are overriding their values each time the loop is run. For i =5, max ([70 50]) = 70! Not s...

5 days ago | 0

| accepted

Solved

Kissing Circles-01
Three circles are mutually tangent to each other and also to a line. find the radius of the smallest circle. The radius of th...

5 days ago

Solved

Number generator
In this problem, a number will be given. starting with the first digit, keep on adding all subsequent digits till the state (...

5 days ago

Solved

modular arithmetic
Given three integers a,b and c, find the remainder when a^b is divided by c. Here, a^b will be well beyond the largest 64 bit in...

6 days ago

Solved

grazing cows
Here is a fun problem I encountered in high school. Two cows are grazing in an enclosed square-shaped field of side length s ...

6 days ago

Solved

Big Integer Sqrt
You will be given a big integer, you should return the square root of it. input: '16' output: '4' have fun!

7 days ago

Solved

Cat's paw - 01
lets imagine a cat, standing on an infinitely long row of tiles. since its a 'cat', string length=3; it takes 3 tiles to stand. ...

7 days ago

Solved

Area-07
This is a follow up of the problem <https://www.mathworks.com/matlabcentral/cody/problems/45341-area-06> in this case, fi...

7 days ago

Solved

Grazing-02
A cow is tied to an outside corner of a rectangular barn of size (a,b) with a rope of length l. What is the maximum area the cow...

7 days ago

Solved

Area-05
The dimension of a rectangle is given. There are two circles of equal size that are inscribed inside it.The circles are tangent ...

7 days ago

Solved

lucky
check whether n is a lucky number <https://oeis.org/A000959>

7 days ago

Solved

Grazing-01
A cow is tied to an outside corner of a rectangular barn of size (a,b) with a rope of length l. What is the maximum area the cow...

7 days ago