How do i make this into code
显示 更早的评论
Hey all i am wondering how i make the below picture into actual code. Any help would be greatly appreciated.

回答(1 个)
Image Analyst
2021-8-19
Did you try using sum(), like
% Create some sample data
N = 4
r = randi(9, N, 1)
u = randi(9, N, 5)
% Now do the equations
ru = r(2:N-1) .* u(2:N-1, :)
usum = sum(ru)
delta_r = 1; % Whatever it is.
uintj = delta_r * ( (1/2) * r(1) * u(1, :) + usum + (1/2) * r(N) * u(N, :))
6 个评论
Dylan Bull
2021-8-19
Dylan Bull
2021-8-19
编辑:Dylan Bull
2021-8-19
Image Analyst
2021-8-19
No. Note that ru is the multiplication of only the middle values, between indexes 2 and N-1, not all indexes between 1 and N.
Dylan Bull
2021-8-19
Dylan Bull
2021-8-19
Image Analyst
2021-8-19
Well I don't know what the first 179 lines of your script do but evidently r is not a column vector.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
