Info
此问题已关闭。 请重新打开它进行编辑或回答。
comparing cells in excel then calculate for the sum
1 次查看(过去 30 天)
显示 更早的评论
So I will try my best to explain this. So I need to find the sum of weight given chart,
I need Matlab go over each column (1-6) and grab valued x marked values and use it for calculation. Since I need the sum of weight, meaning W1+W2+W3....+W6 will bring the sum of the total weight. (here W1=10+13 and W2 = 10+13+8..etc) assuming that marked x can be marked differently for different cases how would I need to program this? I do have some idea that iteration has to be used but not too sure how I can grab certain xs for each column and calculate for Wi.How would I build this program by using while loop? Like i want to say While A(i) <= A(end) (here i am assuming A is a [1 2 3 4 5 6]) so it will check the case for each column. But how would command to matlab at that specific column (example 1), there are A and C and so on... please help! (the size is not always 6 it can be changed so you can't do A(i) <= 6)
Please help! (while loop demonstration would be great!)
0 个评论
回答(1 个)
Star Strider
2018-2-20
I have no idea what you are starting with, since you did not post your chart in a form that we can read and use in a program.
If you can convert the chart to a matrix where it is possible to replace the ‘x’ values by 1 and the empty entries by 0, the maths are straightforward:
Cols = [1 0 1 0; 1 0 1 1; 1 1 0 1; 1 1 1 1; 1 1 0 0; 1 0 0 1]; % Create Matrix
Weight = [10; 11; 13; 8]; % Define Vector
Result = Cols * Weight
Result =
23
31
29
42
21
18
I cannot be certain that we can work with your chart if you do post it.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!