how to loop the following?

Okay I updated it with the photo of what I'm trying. Anyway help will be appreciated.
I'm trying to find force=mass*acceleration
mass is a 20 by 20 matrix
acceleration is a 20 by 1 column vector in the form [0,0,0,Xn,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]'
where Xn is a 1 by 2211 row vector.
Basically I'll be splitting the acceleration Xn term into its components and then add them up using the superposition theory.
I hope the photo helps clear things up.

Respuestas (1)

Image Analyst
Image Analyst el 11 de Feb. de 2017

0 votos

I believe this will do the strange thing you want to do:
x = randi(9, 1, 2211); % Whatever...
mass = ones(20);
accel = ones(size(mass, 1), 1);
accel(2) = sum(x, 2)
force = mass * accel

2 comentarios

ramlal
ramlal el 11 de Feb. de 2017
hmmm but accel is really a column vector of zeros in my case with the 4 spot being X value in the 2211 column. So how would you phrase that? I'm not sure if you see what I'm saying
Image Analyst
Image Analyst el 11 de Feb. de 2017
I'm seeing your photo, where you showed various x elements but always in the second row, not in "the 4 spot" (meaning the 4th row I guess). If you want it in the 4th row instead, just do this:
accel(4) = sum(x, 2)

La pregunta está cerrada.

Etiquetas

Preguntada:

el 11 de Feb. de 2017

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by