Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to use a summation for values ranging from 0 to 20?what is the proper syntax ?

1 回表示 (過去 30 日間)
L K
L K 2016 年 10 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a datasheet with two columns having values, want to use a summation for all those values.can anyone help?
  10 件のコメント
Guillaume
Guillaume 2016 年 10 月 25 日
So far, after 8 comments, all we know is that you have some data and you want to do something with it, which is not sum but a "long equation" and you want to do it the complicated way.
Not much to go on...
L K
L K 2016 年 10 月 25 日
Its alright, i found it, Thanx

回答 (1 件)

KSSV
KSSV 2016 年 10 月 25 日
clc; clear all ;
data = rand(100,1) ;
% sum of only those numbers which are less then 0.5
d = data(data<0.5);
sum1 = 0 ;
for i = 1:length(d)
sum1 = sum1+d(i) ;
end
% Add first twenty only
sum2 = 0 ;
for i = 1:20
sum2 = sum2+data(i) ;
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by