MATLAB Answers

comparing cells in excel then calculate for the sum

조회 수: 1(최근 30일)
PetronasAMG
PetronasAMG 20 Feb 2018
답변: Star Strider 20 Feb 2018
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

로그인 to comment.

답변(1개)

Star Strider
Star Strider 20 Feb 2018
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

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by