Community Profile

# David Hill

Last seen: Today 2017 以来アクティブ

Electrical Engineering with minors in Computer Science, Mathematics, and Creative Writing.

Working as Undergraduate Research Assistant in the field of Computational Photonics

All

バッジを表示

#### Content Feed

How to reset a variable in a for loop?
Use indexing. X=1+rand(1,10); for i=1:10 Y=X(i)+5;%whatever you do. end

1日 前 | 0

Convert list of indices to array
x=reshape(yourMatrix(:,4),[3],[3],[3]);

2日 前 | 1

indexing into an array
[~,idx]=ismember(B,A(:,1)); C=A(idx,:);

2日 前 | 0

| 採用済み

Initializing all rows with one set of values in one half and another set in the other half
cA=repmat([cA0*ones(1,(N-1)/2+1),Kw/cB0*ones(1,(N+1)/2-1)],number_of_rows,1);

2日 前 | 0

Random number selection from matrix column and from decimal number
[A(randi(3,1,4)+[0 3 6 9]),rand(1,2)];

11日 前 | 0

How to store array?
x=0:.1:3; for k=1:length(x) A=[5*x(k),0;2*x(k)^2,1] B=[0;2.55] Y(:,k)=A\B; end

11日 前 | 1

How to fill a matrix with formula
y=reshape(y,5,[])';

12日 前 | 1

| 採用済み

Create table of means from multiple tables
temp=T1.Properties.VariableNames; T=array2table((T1{:,:}+T2{:,:}+T3{:,:})/3); T.Properties.VariableNames=temp;

14日 前 | 0

Printing out zeros as empty character for a tex file
s=sprintf([num2str(i) ' & ' num2str(myData(i,1), format)... ' & ' num2str(myData(i,2), format) ... ' & ' nu...

| 採用済み

Change error bar colour and data point colour in a loop
errorbar(x(i),y(i),err(i),'o', 'LineWidth', 2, 'MarkerFaceColor','g','Color','g');

| 採用済み

How do I randomly extract 20 segments of data from a signal?
You could just keep matrix form with a 3rd dimension for k=1:20 newMatrix(:,:,k)=yourMatrix(randperm(60001,1000),:); end

Plotting the function of single variable
n0 = 400; r0 = 1/n0; gamma = 1.26; p=20;%assumed s=.7;%assumed P=1:(p+1); r=r0*gamma.^(0:p); N=@(t)r0*n0*(2*s/(2*s-1))^(p...

how to plot cell array continuously as line
y = cell2mat(A(1:20)); plot(1:numel(y),y);

selecting 2 bits from given input bit stream alternatively
A=reshape(a,2,[])'; b=A(1:2:end,:); c=A(2:2:end,:);%matrix form %you could also convert to binary A=sum(A.*[2 1],2); b=dec2...

| 採用済み

how to solve equation
y=zeros(size(x)); y(x==1)=3; y(x~=1)=x(x~=1).^3+55;

How can I properly format small numbers using num2str?
soly=num2str(y,'%.3E') solx=num2str(x,'%.3E')

| 採用済み

how to sum array
B'+A;

Insert column of strings into numerical matrix
Cannot put date strings into a matrix of numbers. Convert date strings to numbers (datenum) and insert. If you want the date str...

how do i write this in matlab?
syms x i=0:.1:1; for k=0:10 for j=1:11 K(j,k+1)=int(euler(k,x),x,[0,i(j)]); end end K=double(K);

| 採用済み

How to reverse a Ax=b system of equation to find an A value from a x and b value
R1=4000; R2=8000; syms R3; R4=2000; R5=5000; v=125; A=[0 R2 0 R4 0 0 -R1 R2 -R3 0 0 0 0 0 R3 R4 -R5 0 1 1...

| 採用済み

How to calculate coefficient of variation for every element in Matrix?
cv=std(datan,0,'all')/mean(datan,'all');

Save vales in Harry in a for loop
No loop needed. Ri_A=numbA_IntStat./(E_i.*cos(numbGrad).*ds);%assuming all the same sized variables

how can i integrate a function which has three variables but has to integrate it with respect to only one variable
For example: syms a b d e t; f=d^2*cos(e)/exp(t); I=int(f,e,a,b);

Surface plot from excel data
a=readmatrix('test1.xlsx'); x=a(1,2:end); y=a(2:end,1); z=a(2:end,2:end); [X,Y]=meshgrid(x,y); surf(X,Y,z)

| 採用済み

I'm new in matlab and I'm having trouble with the coding
x=(2*s*(4*s^2+19*s+20))/(20*s^4+66*s^3+73*s^2+57*s+30);%s is scalar x=(2*s.*(4*s.^2+19*s+20))./(20*s.^4+66*s.^3+73*s.^2+57*s+30...

Multiply each element of a matrix by different element from another matrix
massg=10^-5:10; %mass [g] mass=massg/1000; %mass [kg] Ra_leo=2000; Ra_geo=35786; % altitude[km] R=6378; %Radius of Earth [km]...

Improving the speed of a double for loop through vectorization or changing summation indices
What is rep doing? Seems to just be multiplying. for rep = 1:10000 for p=0:N_M_min for q=0:p coeff(p+1) = coeff(...

2ヶ月 前 | 0

A simple rout algorithm in finding the way from point (0,0) to a random point (x1,y1) in a block
I would use a graph. M=zeros(100);%adjacency matrix start r=randperm(100,11);%ten random nodes with last node the end point e...

2ヶ月 前 | 1

| 採用済み

How to use multiple break statments
for i = 1:100 if ~(sln2.Error<=1) Ext.W22=beta*Ext.W22; Ext.W22List(i) = Ext.W22; end sln3.Erro...

2ヶ月 前 | 0

| 採用済み

Find minimum and maximum from same matrix
m=yourMatrix; m(m<=0)=inf; Min=min(m,[],'all'); m=yourMatrix; m(m>=0)=0; Max=-max(abs(m),[],'all');

2ヶ月 前 | 0