0

I have 3D velocity data which i import into matlab from different time steps the data is then stored into a single array, so for e.g.

A = 1.9003018979277591 3.9313938050246353 1.9550611401555038 4.4729389195345890 -0.1923084604908526 1.9079954278788835 3.9313938050246353 1.9236081195213699 4.4656360727573148 -0.2883623514359477 1.9156889578300083 3.9313938050246353 1.8600046726104833 4.4633941493518368 -0.3745597398775253 1.9233824877811327 3.9313938050246353 1.7774536511804597 4.4684591066449331 -0.4468743057900739 1.9310760177322572 3.9313938050246353 1.6785880816271836 4.4792352570817320 -0.5015682599033333 1.9387695476833817 3.9313938050246353 1.5789717220681783 4.5015318412785614 -0.5414950892833046 1.9464630776345062 3.9313938050246353 1.4803758914752310 4.5382688538970140 -0.5671639103123366 1.9541566075856309 3.9313938050246353 1.3954540252731027 4.5972897305115961 -0.5822441272159316 1.9618501375367554 3.9313938050246353 1.3209857949421817 4.6788923156623099 -0.5844651059587465 

The data above is a single array which will contain all the V velocity values for a range of time steps. i want to now multiply the first value of each column by the following, so e.g 1.9003*1.907, then 1.9003*1.915, so the same for the next column and for any number of columns. i want to store the values of these into another single array. i need some help on how to do the multiplication.

0

2 Answers 2

2

Use bsxfun with times like this:

req = bsxfun(@times, A(1,:),A(2:end,:)); 

If you have MATLAB R2016b or later, you can use implicit expansion like this:

req = A(1,:) .* A(2:end,:); 
Sign up to request clarification or add additional context in comments.

Comments

1

This should do, although I am sure there is a more elegant way

B = repmat(A(1,:), size(A, 2), 1); C = A; C(2:end,:) = A(2:end,:).*B(2:end,:); 

A is your initial matrix and C is your final answer.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.