Community Profile

# David Hill

##### Last seen: Today
3,474 total contributions since 2017

View all

Contributions in
View by

How do i build a matrix asking the user for inputs?
If allowed, I would build the entire matrix with one input. yourMatrix=input('Input your matrix in the given format, for exampl...

11 hours ago | 0

How can do this?
c=1; while 1 n(c)=input('Enter positive number'); if n(c)<0 n=n(1:end-1); break; end c=c+1; end fpr...

11 hours ago | 0

Multiplication of 2 sets to get all possible outcomes
a = 0:0.01:0.2; b = 0:pi/12:pi; [A,B]=meshgrid(a,sin(b)); C=A.*B; c=unique(C(:)');%if you only want unique outcomes.

12 hours ago | 0

| accepted

How to compute the sum term ?
alpha = 0.6; U(1)=1;%you need to specify U(1) and U(2) U(2)=.5; S=2^(1-alpha)*(U(1)-U(2)); U(3)=(U(2)+S)/2; for n=3:50 ...

12 hours ago | 0

| accepted

Displaying all elements of a matrix less than -50
e=M(M<-50)

1 day ago | 0

| accepted

How can I fix this Infinite While loop?
a = 12; b = 13000; x = .2004/a % Interest payment = 700;%I assume you want a constant payment until the last payment count=...

4 days ago | 0

Why can't I calculate the definite integral?
F=vpa(F)

4 days ago | 0

| accepted

creating a matrix from 2 vectors and a function loop

4 days ago | 0

| accepted

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 =@(...

8 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);

10 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)]; ...

10 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)...

10 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 ...

10 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

10 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...

11 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...

11 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,:));

11 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 ...

11 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 : '); ...

11 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);

11 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;

15 days ago | 1

| accepted

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

18 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;...

18 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...

19 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); ...

19 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));

19 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);

19 days ago | 0

| accepted