Creating a Square Matrix from a Variable “Plug-In”, Keeping Each Row In The Matrix Fixed To One Value
Hello everyone,
I am trying to create a square matrix that is N x N in size. In my case, N = 23.
I have a variable that’s called "Kernel". This variable is calculated as an equation in terms of "z" and "z_prime".
My values in z_prime will vary from L / 2N to (2N-1)*(L/2N) , in steps of "L/N".
My "z" variable will be fixed.
My goal is to generate a matrix with my "Kernel" variables that have different values of "z_prime", but keeping "z" fixed as a variable.
However, I need to keep each row of the "Kernel" matrix fixed to one "z_prime" value.
Which means each row will have its own "z_prime" value and thus each row will have its own "Kernel" value.
I attached my "value list" of "z_prime".
See excel sheet attached:
z_prime_value_list.xlsx
I attached a screenshot showing the type of matrix I am trying to generate
See .PNG file attached:
Kernel Matrix.png
…all the way until K(z,z_prime_23).
In my attempt, I have tried to use for loops and creating function handles to make it easier to generate this matrix. However, I still got a "1 x 23" matrix instead of the "23×23" matrix I was trying to get.
I attached my MATLAB Code for reference.
See MATLAB .m file attached:
Square_Matrix.m
I know that there is a way to use "nested" for loops to generate a square matrix of an "N X N" size. However, I wasn’t quite sure on how to implement that in MATLAB for my case.
I have tried to look through different questions/answers on the Mathworks Forum regarding square matrices. However, I wasn’t able to find anything that was relevant to my case.Hello everyone,
I am trying to create a square matrix that is N x N in size. In my case, N = 23.
I have a variable that’s called "Kernel". This variable is calculated as an equation in terms of "z" and "z_prime".
My values in z_prime will vary from L / 2N to (2N-1)*(L/2N) , in steps of "L/N".
My "z" variable will be fixed.
My goal is to generate a matrix with my "Kernel" variables that have different values of "z_prime", but keeping "z" fixed as a variable.
However, I need to keep each row of the "Kernel" matrix fixed to one "z_prime" value.
Which means each row will have its own "z_prime" value and thus each row will have its own "Kernel" value.
I attached my "value list" of "z_prime".
See excel sheet attached:
z_prime_value_list.xlsx
I attached a screenshot showing the type of matrix I am trying to generate
See .PNG file attached:
Kernel Matrix.png
…all the way until K(z,z_prime_23).
In my attempt, I have tried to use for loops and creating function handles to make it easier to generate this matrix. However, I still got a "1 x 23" matrix instead of the "23×23" matrix I was trying to get.
I attached my MATLAB Code for reference.
See MATLAB .m file attached:
Square_Matrix.m
I know that there is a way to use "nested" for loops to generate a square matrix of an "N X N" size. However, I wasn’t quite sure on how to implement that in MATLAB for my case.
I have tried to look through different questions/answers on the Mathworks Forum regarding square matrices. However, I wasn’t able to find anything that was relevant to my case. Hello everyone,
I am trying to create a square matrix that is N x N in size. In my case, N = 23.
I have a variable that’s called "Kernel". This variable is calculated as an equation in terms of "z" and "z_prime".
My values in z_prime will vary from L / 2N to (2N-1)*(L/2N) , in steps of "L/N".
My "z" variable will be fixed.
My goal is to generate a matrix with my "Kernel" variables that have different values of "z_prime", but keeping "z" fixed as a variable.
However, I need to keep each row of the "Kernel" matrix fixed to one "z_prime" value.
Which means each row will have its own "z_prime" value and thus each row will have its own "Kernel" value.
I attached my "value list" of "z_prime".
See excel sheet attached:
z_prime_value_list.xlsx
I attached a screenshot showing the type of matrix I am trying to generate
See .PNG file attached:
Kernel Matrix.png
…all the way until K(z,z_prime_23).
In my attempt, I have tried to use for loops and creating function handles to make it easier to generate this matrix. However, I still got a "1 x 23" matrix instead of the "23×23" matrix I was trying to get.
I attached my MATLAB Code for reference.
See MATLAB .m file attached:
Square_Matrix.m
I know that there is a way to use "nested" for loops to generate a square matrix of an "N X N" size. However, I wasn’t quite sure on how to implement that in MATLAB for my case.
I have tried to look through different questions/answers on the Mathworks Forum regarding square matrices. However, I wasn’t able to find anything that was relevant to my case. matrices, for loop, for loops, nested for loop, nested for loops, function handles MATLAB Answers — New Questions