I have three matrices A,B,C C is being passed to a function in the following loop
for i=0:n
func(C)
end
At i =0 C = A and at i = n C = A+B
I'm pretty sure that I'm supposed to use interpolation but I'm not sure how to go about doing that

 채택된 답변

Voss
Voss 2022년 4월 3일

0 개 추천

A = ones(2)
A = 2×2
1 1 1 1
B = magic(2)
B = 2×2
1 3 4 2
A+B
ans = 2×2
2 4 5 3
n = 3;
for i = 0:n
% i=0 -> C=A
% i=n -> C=A+B
C = A+B*i/n
end
C = 2×2
1 1 1 1
C = 2×2
1.3333 2.0000 2.3333 1.6667
C = 2×2
1.6667 3.0000 3.6667 2.3333
C = 2×2
2 4 5 3

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 4월 3일

0 개 추천

Are they 1-D vectors or 2-D matrices? And I don't see "A and B in a for loop" as you said. Why are they missing? Is this your homework? Did you try
i = 0:n;
C = A + (i/n) .* B

카테고리

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

제품

릴리스

R2021b

태그

질문:

2022년 4월 3일

답변:

2022년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by