Output doesn't seem right

2 ビュー (過去 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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by