For loop and matrices w/ different elements?
B(i)=[m2.*A2x(i); m2.*A2y(i); I2*a2; m3*A3x(i); m3*A3y(i); I3*a3(i); m4*A4x(i)-F4x(i); 0];%ne...

ongeveer een maand ago | 0

| accepted

How to code with for loop loops without using ndgrid?
count=0; for c=5:6 for b=3:4 for a=1:2 count=count+1; d(count,:)=[a,b,c]; end ...

ongeveer een maand ago | 0

How to divide a vector into small groups
x=randi(100,30,1); X=reshape(x,2,[]); [~,idxGroup]=find(X==x(15));

ongeveer een maand ago | 0

| accepted

Extracting the sub-matrix
A = [1 2 3; 4 5 6; 7 8 9]; B=A(1:2,2:3); E=blkdiag(zeros(2),A);

ongeveer een maand ago | 1

| accepted

plotting a 2-colum 2d array
plot(a(:,1),a(:,2));

ongeveer 2 maanden ago | 1

Not enough Input arguments in integral function
s=0:100; for t=1:numel(s) fun_W=@(k)real(c_k(k))./k.*sin(k*s(t)); W(t)=2/pi*integral(fun_W,0,Inf); end fu...

ongeveer 2 maanden ago | 1

| accepted

How can I sum each 3 columns array?
m=movsum(x,3); y=m(:,1:3:end);

ongeveer 2 maanden ago | 1

| accepted

Cropping images around the center of an image with a particular size

ongeveer 2 maanden ago | 0

Too many for loops, how to approach rearranging arrays problem differently?
a=1:10; b=10:19; sa=0;sb=0; for k=2:numel(a) sa=sa+sum(nchoosek(a,k),'all'); sb=sb+sum(nchoosek(b,k),'all'); end

ongeveer 2 maanden ago | 0

How can I fix random numbers in a for loop?
t=1:.1:10; for k=1:10 s1=randi(5)*sin(1*t)+randi(5)*sin(2*t); s2=randi(5)*sin(1*t)+randi(5)*sin(2*t); Diff(k)=(s1-s2); e...

ongeveer 2 maanden ago | 1

| accepted

For loop broken ?
rho = (20-h(n)/1000)/(20+h(n)/1000)*1.225;%h(n) is always going to be zero rho = (20-h(n-1)/1000)/(20+h(n-1)/1000)*1.225;%did y...

ongeveer 2 maanden ago | 0

| accepted

How to save for loop output to column vector
No loops needed, although you never defined hbar. fvf= 2888.7; ccm = 3*10^8*100; h = 6.63*10^-34; v1 = ccm*fvf; invAvkg = 1...

ongeveer 2 maanden ago | 0

| accepted

Function Approximation and Interpolation
Something like this. f = @(x) exp(-x.^2); x = linspace(-1, 1, 9); G=vander(x); y=f(x); c=G\y'; f1=@(x)polyval(c,x); t=lin...

ongeveer 2 maanden ago | 0

| accepted

Finding top and bottom 10% of data
n=round(.1*numuel(yourMatrix)); [~,idx]=sort(yourMatrix); bottom=yourMatrix(idx(1:n)); top=yourMatrix(idx(end-*n+1:end));

ongeveer 2 maanden ago | 0

Converting a matrix to string
string(Z);

ongeveer 2 maanden ago | 0

How to plot x and y
t=0:.1:100; x=3*t; y=2t; plot(x,y);

ongeveer 2 maanden ago | 0

Can someone please debug my code?
You need to use some cell arrays since the number of lines is different in the loops. Also the calculation for Q has something w...

ongeveer 2 maanden ago | 0

Apply the same matrix index to another matrix (bootstrap for matrix processes)
g=[]; [a,b]=size(indices); for k=1:b g=[g,vector(repmat(indices(:,k),1,b)+[0:a:(b-1)*a])]; end

ongeveer 2 maanden ago | 0

How can I solve an equation with 4 vectors of unequal length?
Use ndgrid() g = 9.80665; mb = 1:0.5:20; r = 0.01:0.01:0.15; omega = 1800:1000:20000; omegarad =...

ongeveer 2 maanden ago | 1

| accepted

No reason to use symbolics. round(sum((-1).^(2:58)./(1:57).^2),4);

ongeveer 2 maanden ago | 0

why is my code giving me a parse error
x=0.1; %beats=A(1,30); There is no A defined and you are indexing into it! for k=1:30 A(k)=2*x*(1-x); %need 2*, if you wan...

ongeveer 2 maanden ago | 0

When I try to solve this equation, this message appears, how can I solve this problem?
k=2.7904; R=0.20491; syms a Eqn=a./(1+(2*k*(1-a))+(1+(2*k/3)).*(sqrt(3*(1-a))))==R;%messed equation up (need k*(1-a)) s = v...

ongeveer 2 maanden ago | 1

| accepted

Using fzero to find values of B for given values of A
A=5:5:25; for k=1:numel(A) fun = @(x) (1-0.5*cos(A(k))-1.2*cos(x)).^2+(0.5*sin(A(k))+1.2*sin(x)).^2 -1; B(k)=fzero(fun,1)...

ongeveer 2 maanden ago | 1

Get the position of the next in row and next in column in a matrix
matlab indexing is down and then across. A=[1 0 -2 0 0;2 8 0 1 0;0 0 3 0 -2;0 -3 2 0 0;1 2 0 0 -4]; a=A';%gets your indexing ...

ongeveer 2 maanden ago | 0

Delete values from two column vectors with same position
m=[A,B,C];%need to form matrix m(ismember(m(:,2),[8 9 10]),:)=[];%entire rows are deleted where 8,9,10 are in column 2 (B) m(i...

ongeveer 2 maanden ago | 0

| accepted

how to get the first index that satisfy my condition
j=find(abs(x)<=abs(.05*x(end)),1);%I think you need <=

ongeveer 2 maanden ago | 0

I need help creating a loop for an experiment
Number the videos produced each day starting at 1 and going to 1050 (21 days, 50 videos each day). videoPool=[]; K=[1,2,3,4,5,...

ongeveer 2 maanden ago | 0

| accepted

changed value of the specific matrix
yourMatrix(3000:3100)=1; yourMatrix(1500:1600)=1;

ongeveer 2 maanden ago | 0

| accepted

how to read data from excel file