Output doesn't seem right

조회 수: 4 (최근 30일)
Sherman Ng
Sherman Ng 2022년 3월 15일
답변: Prateek Rai 2022년 3월 22일
Hi, so this is the output that I have so far, but the question has T-i and T-0 variables and I'm not sure what to do with those variables.
So I replaced T-i and T-0 with x and y but apparently the output is wrong. Apparently the goal is to produce a 3*3 matrix.

답변 (1개)

Prateek Rai
Prateek Rai 2022년 3월 22일
Hi,
The output does not seem right because you are mixing 2 things together. In the line 41 and line 42 of your code you are doing:
x = 20; y = 10; % Line 41
[x, y] = meshgrid(1:(n * m), 1:(n * m)); % Line 42
So because of the 42nd line, x is now not 20 and y is not 10 but rather output of the meshgrid.
This is why you have a warning at variable x and variable y at line 41. If you hover over them you will see messages like: "The value assigned to variable 'x' might be unused" and "The value assigned to variable 'y' might be unused" respectively.
To correct this, you can rather use variables like T_i and T_0 and save the respective values in these variables and don't mix it up with x and y.
So the code should look like:
x = 20; y = 10; % Line 41
[x, y] = meshgrid(1:(n * m), 1:(n * m)); % Line 42
You can refer to Variable Names MathWorks Documentation page to learn more on proper variables naming and avoid conflicting.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by