finding the computation for n columns

Hi
Given a a vector table z with column and row of 1200 and 1200 respectively
I want to compute the following for each rows
z = ( T R S T V............n column)
first column T
K = 3;
c1 = sort(T.distance(1:2:end));
c2 = sort(T.distance(2:2:end));
s1 = sum(c1(1:K))/sum(c2(1:K )) ;
second column R
K = 3;
c1 = sort(R.distance(1:2:end));
c2 = sort(R.distance(2:2:end));
s2 = sum(c1(1:K))/sum(c2(1:K )) ;
disp(s2);
How do I make this computation using a small code for n columns
Thank you in advance
Tino

답변 (1개)

madhan ravi
madhan ravi 2019년 5월 14일
편집: madhan ravi 2019년 5월 14일

0 개 추천

Z=z{:,:};
K = 3;
c1 = sort(Z(1:2:end,:));
c2 = sort(Z(2:2:end,:));
s1 = sum(c1(1:K,:))./sum(c2(1:K,:))

댓글 수: 11

Thanks Madhan
But I am getting this error when I try to compute
J = Z{:,:};
K = 3;
c1 = sort(J(1:2:end,:));
c2 = sort(J(2:2:end,:));
s1 = sum(c1(1:K,:))/sum(c2(1:K,: )) ;
disp(s1);
Error
Brace indexing is not supported for variables of this type.
Error in martingale (line 35)
J = Z{:,:};
Thanks in advance
madhan ravi
madhan ravi 2019년 5월 14일
not Z it's z
Tino
Tino 2019년 5월 14일
Hi Madhan
Am still geting the problem
What shall I do
thanks in advance
Brace indexing is not supported for variables of this type.
Error in martingale (line 37)
J = z{:,:};
madhan ravi
madhan ravi 2019년 5월 14일
Attach your table as .mat file.
madhan ravi
madhan ravi 2019년 5월 14일
HI Madhan
I have attached the table below consisting of 1200 rows and 1200 column
the code is to computation for each column
and I am suppose to get 1200 answers
thanks in advance
madhan ravi
madhan ravi 2019년 5월 14일
I'm not able to open your file (try once again) , please don't add an answer just to make a comment
Tino
Tino 2019년 5월 14일
sorry that was an error. Let me add the file again
thanks you in advance
madhan ravi
madhan ravi 2019년 5월 14일
Having trouble opening your file.
Tino
Tino 2019년 5월 14일
Hi Madhan
I had attached the excel file
Hope that is ok
Thanks for your help in advance
Tino
Tino
Tino 2019년 5월 15일
Hi Madhan
Can you see the data now?
Thanks
tino
madhan ravi
madhan ravi 2019년 5월 15일
편집: madhan ravi 2019년 5월 15일
No , I am not able to , there‘s some problem downloading files in my mac.

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

카테고리

도움말 센터File Exchange에서 Communications Toolbox에 대해 자세히 알아보기

제품

릴리스

R2019a

태그

질문:

2019년 5월 14일

편집:

2019년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by