I would like find a matrix from a row and column vectors
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I have a column vector xxb of 201 elements and a row vector rr of 501 elements and I would calculate c =xxb^2+rr^2-R^2 with R=0.05. I have to obtain a matrix of (501x201)size.But i found (501x501). Here is below my code. Anyone has a idea. Thank you in advance, Adam
xb=-5:0.05:5;
xxb=xb';% column vector
r=0:0.01:5;
rr=r;% Row vector
R= 0.05;
for l=1:length(xxb);
for m=1:length(rr);
a(l)=2.*xxb(l);
c(l,m)=xxb(l).^2+rr(m).^2+R^2;
end
end
0 comentarios
Respuesta aceptada
Honglei Chen
el 13 de Ag. de 2012
Editada: Honglei Chen
el 13 de Ag. de 2012
If you want 501x201, then you may want to make rr a column and xxb a row
rr = rr(:);
xxb = xxb(:).';
c = bsxfun(@plus,rr.^2,xxb.^2)+R^2;
or with your current configuration
c = (bxsfun(@plus,xxb.^2,rr.^2)+R^2).';
0 comentarios
Más respuestas (1)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!