Community Profile

# David Hill

##### Last seen: Today
1.498 total contributions since 2017

View all

Contributions in
View by

How do I create a user generated matrix in Matlab?
M = input('Input matrix: '); %then input [1,2;3,4;5,6;7,8;9,10] for a matrix of 5 rows and 2 columns, or whatever matrix you wa...

etwa 16 Stunden ago | 1

| accepted

Is there a way to fill a matrix around the diagonals?
What are the values for the diagonals? I assume you are talking about a square matrix. The below zeros out the diagonals. x=rep...

etwa 16 Stunden ago | 0

| accepted

Index in position 1 is invalid. Array indices must be positive integers or logical values.
Not sure if this will help you or not. Dplate=zeros(30,50); Dplate(2:29,1)=120; Dplate(2:29,50)=40; Dplate(1,:)=40; Dplate(...

etwa 16 Stunden ago | 0

how to use function "find" over matrices
min(x);

ein Tag ago | 0

Not sure best way to code orthogonal diagonalization
For homework, we like to help you figure it out yourself. The code below might help and you could likely find a better way. fun...

2 Tage ago | 0

How to plot binary sine function?
t=0:.01:30: y=sin(2*pi*t/3).*(-1).^floor(t/3);%I think you are missing the 2*pi plot(t,y);

3 Tage ago | 0

Estimating pi using for and while loop for specific tolerance.
function [estpi,n] = mypi(tol) error=1; hits=0; n=0; while error>tol if norm(rand(2,1))<=1 hits=hits+1; end ...

3 Tage ago | 0

| accepted

write max mean as an alternative
a=sort(x) maxvalue=a(end); minvalue=a(1);

3 Tage ago | 0

| accepted

Replace values of matrix by multiples
A(mod(A,10)==0)=999;

3 Tage ago | 0

How can I find the index of the maximum Value in a given subintervall in the normal array
[~,index]=max(Current_array.*(Voltage_array>2));

3 Tage ago | 0

| accepted

Sum up values depending on entries in another column
vector1=['AABABBCAC']'; vector2=[5 2 0 1 4 2 1 3 1]'; vector3=zeros(size(vector2)); a=unique(vector1); for k=1:length(a) ...

3 Tage ago | 1

| accepted

Create Matrix using loop
Look at reshape() function. reshape(yourMatrix,108,108,192);

3 Tage ago | 0

| accepted

Cell arrays and strings
String arrays, a=["abc","defg"], are different from character arrays, a=['abcdefg']. Each character is a different element in th...

4 Tage ago | 0

how to solve two equations in one variable
syms x; J= D= eq=exp(-x)-52*x^3==J/D;%combine the equations yourself vpasolve(eq,x);

4 Tage ago | 0

| accepted

Building up a Matrix using for LOOP and summation
I believe the below is correct. I=eye(4); u=zeros(4); u(1,1:4)=a(1,1:4); I(1:4,1)=a(1:4,1); for i=2:4 for j=1:4 ...

5 Tage ago | 1

| accepted

Error using / Matrix dimensions must agree.
[P,h]=meshgrid(linspace(0,300,300)*10^3,linspace(5,20,15)*10^-6); E=130*10^9; a=150*10^-6; Z= (0.216*P*a^4)./(E*h.^3); surf(...

5 Tage ago | 0

skip the value in for-loop
a = 27; c = 11; m = 54; x(1)=2; for i=2:25 x(i) = (mod(a * x(i-1)+c ,m)) end x(2:end)

5 Tage ago | 0

get user input in the form of an integer
The user inputs two integers and they are stored in the user_input array. user_input = input('Please enter min and max in the f...

5 Tage ago | 0

Simple operations with struct
yourStuck.field(yourStuck.field<50000)=0;

5 Tage ago | 0

How can I extract non-consecutive indices from a vector?
If you have a density array (d), then to extract the 1,3,6 elements: extracted_elements=d([1,3,6]);

5 Tage ago | 1

| accepted

How do I stop these popups that cover the code I'm writing?
To set Keyboard Preferences, on the Home tab, in the Environment section, click Preferences. Select MATLAB > Keyboard, and then...

6 Tage ago | 0

| accepted

Variables in function are not stored in workspace
Click on the line in the function where you want to place a breakpoint. Execute the function. The function will stop at the brea...

6 Tage ago | 0

Error using struct, too many input arguments
Works perfectly for me. What version of MATLAB are you using? cyl=struct('code','x','dimensions',struct('rad',3,'height',6),'we...

6 Tage ago | 0

How to use the several average of same class
a=randi(size(values,1),5,1);%randomly choose 5 rows avg=mean(values(a,:),2);%compute mean of the rows

6 Tage ago | 0

| accepted

How do i graph a certain amount of elements in a taylor series.
x=linspace(-pi,pi,100)';%Taylor Series is only good from -pi to pi t=[x,-x.^3/factorial(3),x.^5/factorial(5),-x.^7/factorial(7)...

6 Tage ago | 1

I tried to solve this quistion about
What I got, which should be good for log(x) close to 1, is: t3 = x - (x - 1)^2/2 + (x - 1)^3/3 - 1;

6 Tage ago | 0

How to plot a function with e^-x?
g = 100*(x.^2).*exp(-x); %looks good, just need .* The rest should work

6 Tage ago | 1

| accepted