Unable to perform assignment because the size of the left side is 360-by-1 and the size of the right side is 360-by-360.

1 view (last 30 days)
Hello, I am trying to store numbers from an equation into a new matrix. Below, is the issue code.
asis_d = abs(l_asis(:,2) - r_asis(:,2));
hip_d = abs(l_hip(:,2) - r_hip(:,2));
hip_percent(:,2) = ((0.14*(asis_d))/hip_d) + ((0.5*(hip_d - asis_d))/hip_d);
"Unable to perform assignment because the size of the left side is 360-by-1 and the size of the right side is 360-by-360."
In the first line, I am creating a matrix named asis_d that takes all the numbers in the second column of r_asis and subtracts them from all the numbers in the second column of l_asis. Similarly in the second line, but with the hip variables.
Then, in the third line I am trying to create a new matrix column that stores the results of the equation with each row of number from those columns. So for example, the numbers in the first row of the second column for asis_d and hip_d will get put into the hip_percent equation and give me a new number that I want to store in the first row of hip_percent. And then so on for the second and third and all the numbers in column two of asis_d and hip_d, storing them in their respective column (or row?) in hip_percent.
Why is it creating a 360x360 matrix on the right side instead of a 360x1 matrix? and how can I fix this?
Thank you.

Accepted Answer

Torsten
Torsten on 22 Sep 2022
Edited: Torsten on 22 Sep 2022
Elementwise division is required:
hip_percent(:,2) = 0.14*asis_d./hip_d + 0.5*(hip_d - asis_d)./hip_d;
or simpler
hip_percent(:,2) = -0.36*asis_d./hip_d + 0.5;

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!