Converting Equation of Two Variables Into Matrix Elements - ERROR: Invalid MATLAB indexing or symbolic function definition
Show older comments
Hello everyone,
I am trying to output a square matrix that is N x M in size, where N = M. In my case, N = 3. So this is a "3x3" matrix
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 used as an "integration variable" as seen below.
I am trying to calculate an output called the "Z Matrix" which will integrate the "Kernal" variable across specific ranges.
I attached a .pdf file to clarify my end goal.
See the .pdf file attached:
Z_Matrix_Output.pdf
My Integration Limits for "z" will be going from:
z_start = 0 : L/N : (N-1) * (L/N)
z_end = L/N : L/N : L
As of right now, I'm getting the error:
Invalid MATLAB indexing or symbolic function definition
This is after I tried using "function handles" in my code.
In my attempt, I have tried to use for loops and created function handles to make it easier to generate this matrix.However, I didn't end up with a "N X M" matrix, I just ended up with a "1 X N" matrix.
I know that there is a way to use "nested" for loops to generate a square matrix of an "N X M" 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 converting equations of two variables into "matrix elements". However, I wasn't able to find anything that was relevant to my case.
I attached my MATLAB Code for reference.
See MATLAB .m file attached:
Z_Calculation.m
Accepted Answer
More Answers (1)
Madeeha
on 3 Sep 2024
0 votes
>>a=5
1 Comment
Walter Roberson
on 3 Sep 2024
I do not understand how this solves the problem stated by the poster?
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!