How do i make this into code

조회 수: 6 (최근 30일)
Dylan Bull
Dylan Bull 2021년 8월 18일
댓글: Image Analyst 2021년 8월 19일
Hey all i am wondering how i make the below picture into actual code. Any help would be greatly appreciated.

답변 (1개)

Image Analyst
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
Dylan Bull 2021년 8월 19일
also when attmepting to use this i get the follow error.
Arrays have incompatible sizes for this operation.
Error in project2 (line 180)
ru = r(2:N-1) .* u(2:N-1, :)
Image Analyst
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.

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by