build m x m matrix
이전 댓글 표시
Hello, I wanna build a matrix of m nods. I have some questions:
1-
if F=[-3 2 -3]
for I=1:m;end
B=eye(I)*F; ---------(1)
the problem here is F in eq (1) is not allowed in matlab, what I have to do to built that matrix which affected by different values of m?
2-
A=[5 -3];C=[-3 4];
I wanna use use the three matrices (A,B,C), to get the result to be like
D= [ 5 -3 0 0 0;
-3 2 -3 0 0;
0 -3 2 -3 0;
0 0 -3 2 -3;
0 0 0 -3 4 ]
What do u suggest??
thanks
채택된 답변
추가 답변 (2개)
Image Analyst
2014년 9월 28일
0 개 추천
First of all, in #1, the for loop does nothing. There is an end on the same line and nothing in between so the for loop just iterates but does no commands because no commands are inside it.
Secondly, in your formula 1, I think you want to use .* (element by element multiplication) instead of * (matrix multiplication), and it would only work if F has "I" rows. Since eye(I) is square, F must be have the same number of rows as eye(I) has columns.
For #2, I'm not seeing how matrix D was constructed from A, B, and C. Please explain.
Andrei Bobrov
2014년 9월 28일
F = [-3 2 -3];
A=[5 -3];
C=[-3 4];
out = full(spdiags(ones(5,1)*F,-1:1,5,5));
out(1:2) = A;
out(end-1:end) = C;
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!