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.

Réponses (1)

Image Analyst
Image Analyst le 11 Fév 2017

0 votes

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 commentaires

ramlal
ramlal le 11 Fév 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
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)

Cette question est clôturée.

Tags

Question posée :

le 11 Fév 2017

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by