Community Profile

# David Hill

##### Last seen: 1 day ago
3,466 total contributions since 2017

View all

Contributions in
View by

Could someone explain this straight line function?
It is point-slope form of a line. If the points are a=[x2, y2] and b=[x1, y1], then: m=(a(2)-b(2))/(a(1)-b(1));%slope func =@(...

2 days ago | 0

How can I move the bars in a bar chart?
figure; bar_displacement=.25;%play with this until it is correct bar(x-bar_displacement,y); set(gca,'XTick', x);

4 days ago | 0

ignore NaN values in loop
CC=[]; for i = 2:16 A = walknov(:,i); A = interpft(A(~isnan(A)), 100); if isempty(A) CC=[CC;nan(1,100)]; ...

4 days ago | 0

using for loop plotting problem help me
What are you trying to plot? f= @(x) 3*x.^5+7*sin(x).^2;%I doubt you want sind fd= @(x) 15*x.^4+7*sin(2*x).^2+3*x.^5+7*sin(x)...

4 days ago | 0

Conditional statements on array.
i=reshape(Input,12,[])'>100; Output=zeros(size(i)); for k=1:size(i,1) if nnz(i(k,:))>0 Output(k,:)=1; end ...

4 days ago | 1

what it does mean?
If the matrix 'index' indexed at (1,1) equals 1, then assign S1 =0 and S2 = 0. if index(1,1)==1 S1=0; S2=1; end

4 days ago | 0

for loop issue not all answer printing out
function T = InterestPayment(P,r) for n=1:10 A(n) = P*((r*(1+r)^n)/((1+r)^n-1)); end T= table ((1:10)',A', 'VariableN...

5 days ago | 0

How can I find the nonzero values in an cells array?.
Non_ceros=zeros(length(Index)); for i = 1 : length(Index) for j = 1 : length(Index) Non_ceros(i,j) = nnz(In...

5 days ago | 0

| accepted

wanna creat a matrix of unknowns and write some equations with those unknowns and then take the matrix of coefficients
syms a b c d; t=[a b;c d]; coef=[2 3]; eqn=dot(coef,t(1,:));

5 days ago | 0

for loop help - Newton's method
I would avoid symbolic unless you need to. f = [2,-6,-12,20,42,18]; df = polyder(f); tol=1e-10; error=1; x=[-2,4];%initial ...

5 days ago | 0

| accepted

store user input in an array
user_input= zeros(1,10); for i = 1:10 while user_input(i)<=0 user_input(i) = input('Enter positive real number : '); ...

5 days ago | 0

How to convert binary bits of a vector, say m, after rotating it left by 1 bit, into decimal ?
m = [16; 10]; %use column vector a = fi(m, 0, 8, 0); b = bin(bitrol(a, 1)); c = bin2dec(b);

5 days ago | 0

| accepted

Generate random numbers in the second decimal point
x=1.198:0.1:2.198; x=x-(randi(6,size(x))+3)/100;

9 days ago | 1

| accepted

DOE points normal distrbution
m=standard_deviation.*randn(1,1000)+mean;%generates an array of 1000 numbers

12 days ago | 0

Finding an unknown vector from three known vectors
syms x y z; C=[x,y,z]; A = [125 350 -80]; B = [-115 350 -80]; D = [-15 530 545]; eq1=norm(A-C)==300; eq2=norm(B-C)==300;...

12 days ago | 0

| accepted

Unable to concatenate the table variables 'Var1' and 'Var2', because their types are double and cell.
Why not just readmatrix? What column are you skipping? p = readmatrix('Arrone-pluviometro(36045)-2019-0-24'); p(isnan(p))=9999...

13 days ago | 0

Integrate definite integral with system of differential equations
Can you just do something like this? function dydt = odefun(t, y, c) dydt(1,:) = 1./(1+t.^2) ; % h(t) h=@(x)1./(1+x.^2); ...

13 days ago | 0

| accepted

How can I implement a loop to find the minimum among 5 values
Are you not allowed to use the min() function? function D = myfun(A) D=min([.1 3 5 8 12]./cumprod(A));

13 days ago | 0

Using fzero on function
y=@(x)x.^6-2.*cos(x); x=linspace(-3,3,100); plot(x,y(x)); z(1)=fzero(y,-1); z(2)=fzero(y,1);

13 days ago | 0

| accepted

How to Define a Symbolic Continued Fraction
function L = continuedFraction(N,n) syms A B; if n==0 L=0; else L=1/(B/(N-1)+A/N+continuedFraction(N,n-1)); end R...

14 days ago | 1

FSOLVE with For loop
Not sure what values you what for b, but you will not to do a surf plot or plot3 (3d plot) f=@(x,b)x.^3.*b+exp(-b.^2)+x.*b-500;...

14 days ago | 0

Issue with creating a plot from two for loops
a=1.63279*10^-6; b=264.9889; T=373:10:1273; Mu = (a*T.^0.5)./(1+b./T); n = 0.666; T0 = 273; Mu0 = 1.375*10^-5; MuT = Mu0....

14 days ago | 1

Solved

Replace secondary diagonal elements of a square array
Replace all the secondary diagonal elements of the square array A with the number n Example: A = [1 2 3 4 5 6 ...

23 days ago

Solved

Compound interest - number e
A moneylender wants to receive his annual interest of 12% more frequently. If he receives his interest rate every six months,...

23 days ago

Solved

Find the slope

23 days ago

Solved

Potential energy calculation

23 days ago

Solved

Total energy

23 days ago

Solved

Kinetic energy calculation

23 days ago