필터 지우기
필터 지우기

Table's rows pow and the sum

조회 수: 1 (최근 30일)
Thanos Lampridis
Thanos Lampridis 2016년 9월 2일
답변: dpb 2016년 9월 2일
I'm building this code I'm building this code
>> A=imread('C:\Users\ADMIN\Desktop\canada.bmp');
>> level=graythresh(A)
level =
0.6235
>> BW=im2bw(A,level);
>> C=imcontour(BW);
>>array2table(C.', 'VariableNames', {'J', 'K'});
So far i have a table with 9540 rows and 2 colls.I want to MULTIPLY each row's data but first pow them.And then to get the final summary of all rows FOR EXAMPLE :
J K
1 1.1
2 2.8
3 4.3
TOTAL SUM=(1^2)*(1.1^2)+(2^2)*(2.8^2)+(3^2)*(4.30)^2

답변 (1개)

dpb
dpb 2016년 9월 2일
totSum=sum(C(:).^2);
or
totSum=dot(C(:),C(:));
Not sure if either has speed advantage with size or not; haven't tested for that...

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by