how to calculate a serie of a function with two variables
显示 更早的评论
hi everybody. i want to calculate the sum of a serie that has a function which has two variables named 'xi' and 'eta'. 'xi' and 'eta' are the coordinates of 4 points. for example i want to calculate the sum of the serie from point 1 to point 4 and in each point 'xi' and 'eta' has a specific value. can anyone help me how to write the code??
回答(4 个)
dpb
2015-2-22
xi=[list of four values];
eta=[list of four more presumably different values];
func=yourfunction(xi,eta); % compute the function
sumFunc=cumsum(func);
2 个评论
Omidreza Ghafarinejad
2015-2-22
dpb
2015-2-22
How do we Know that? You didn't show any more of your work than your original question... :(
Shoaibur Rahman
2015-2-22
% xi eta
x =[1 2;...
3 4;...
4 5;...
6 7];
y = sum(x) % only sum of all elements along each column
y = cumsum(x) % cumulative sum along each column
Image Analyst
2015-2-22
0 个投票
Be more specific. Why can't you give us the series? Is it homework or something? If you don't get more specific then you'll just get more answers like dpb's (which is all your fault rather than dpb's because you were not specific enough to be able to answer your question).
What's wrong with using the sum() function, or even a brute force for loop()?
2 个评论
Omidreza Ghafarinejad
2015-2-22
编辑:Omidreza Ghafarinejad
2015-2-22
Image Analyst
2015-2-22
If you want to sum a 3D matrix "j" between certain rows and columns, do this
subArray = j(row1:row2, col1:col2, :);
theSum = sum(subArray(:));
Omidreza Ghafarinejad
2015-2-24
0 个投票
2 个评论
Charu Yadav
2022-3-29
I am facing the same problem. Can you help me?
Torsten
2022-3-29
Nobody will work through all the contributions to see what "the same problem" is.
Open a new question.
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!