필터 지우기
필터 지우기

How to multiply 4 columns together in a 40x7 table

조회 수: 2 (최근 30일)
Alex Jones
Alex Jones 2020년 4월 20일
답변: BALAJI KARTHEEK 2020년 4월 20일
Hi,
How do I multiply 4 columns of a table together and then output the answer in another column inside the same table. Additionally how do I repeat this for all 40 lines of the table?
  댓글 수: 5
Alex Jones
Alex Jones 2020년 4월 20일
I have worked out a way to do this but I am now getting: Operator '.*' is not supported for operands of type 'cell'.
How do I fix this as I am multiplying within a table?
Ameer Hamza
Ameer Hamza 2020년 4월 20일
Alex, as you mentioned, the variables are of type cell and double. At best, we can make a guess, but the suggested solution that will probably not work. It will be better if you can attach a sample table, similar to the original table you have. It will make it much easier to suggest a solution quickly.

댓글을 달려면 로그인하십시오.

답변 (1개)

BALAJI KARTHEEK
BALAJI KARTHEEK 2020년 4월 20일
Hope this will help u out.....
in variable a u keep ur input matrix and in while size(a,2)<7: instead of 7 u keep ur no of required columns in ur case it is 41, if u have any furher doubts u can feel to contact me
clc
clear all
format long
a= [1 2
1 2
1 2];
while size(a,2)<7
for i=1:size(a,1)
b(i)=1;
for j=1:size(a,2)
b(i)=b(i)*a(i,j);
end
end
a(:,size(a,2)+1)=b;
end
display(a)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by