조회 수: 17 (최근 30일)
Ivan 2024년 2월 16일
편집: Dyuman Joshi 2024년 2월 17일
What I currently have is
% Define the ordered bases
B = [1 0 4; 0 -3 1; 1 2 0];
C = [3; 2; -1; 5];
% Define the linear transformation
T = @(x) [x(1) + x(2); -2 * x(3)];
% Compute the images of the basis vectors in B under the transformation
B_images = zeros(2, size(B, 2));
for i = 1:size(B, 2)
B_images(:, i) = T(B(:, i));
end
% Create the augmented matrix D
D = [C, B_images];
% Display D
disp('Matrix D:');
disp(D);
and it gives me
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in solution (line 15)
D = [C, B_images];
I am trying to find the 2 x 5 matrix D, with these intructions,find the matrix represenatation for the linear transformation defined by T (x1 x2 x3) = {x1 + x2; -2x3} with respect to the ordered bases
B = [1 0 4; 0 -3 1; 1 2 0];
C = [3 2; -1 5];
##### 댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
VBBV 2024년 2월 16일
You defined B incorrectly May be you meant C incorrectly
Dyuman Joshi 2024년 2월 17일
Yes, thanks for the correction, @VBBV.

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

### 답변 (1개)

Steven Lord 2024년 2월 16일
Let's compare the C matrix that you defined in your code:
C1 = [3; 2; -1; 5]
C1 = 4×1
3 2 -1 5
and the one defined by what I assume is the text of the assignment you were given:
C2 = [3 2; -1 5]
C2 = 2×2
3 2 -1 5
They aren't the same size. Can you place a 2-by-1 vector "side by side" with a 4-by-1 vector and have them "line up" without extra elements sticking out? To concatenate arrays in MATLAB, they have to have the same size in the dimension along which you're trying to concatenate them. So the following works; we're trying to put b and C2 side by side so they have to have the same number of rows:
b = [4; 6]
b = 2×1
4 6
D = [b, C2]
D = 2×3
4 3 2 6 -1 5
This too would work because when putting b "on top" of C1 they have to have the same number of columns.
E = [b; C1]
E = 6×1
4 6 3 2 -1 5
But this wouldn't because b and C1 don't have the same number of rows. Nor would putting b "on top" of C2.
F = [b, C1] % error
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
G = [b; C2] % would also error

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

### 카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by