Output doesn't seem right

2 views (last 30 days)
Sherman Ng
Sherman Ng on 15 Mar 2022
Answered: Prateek Rai on 22 Mar 2022
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.

Answers (1)

Prateek Rai
Prateek Rai on 22 Mar 2022
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.

Tags

Community Treasure Hunt

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

Start Hunting!