What exactly is the error? I run your plot_y.m file, the function y_junction that is call inside the plot_y is missing here. We can debug if you can share your y_junction function source code.
You must provide the y-junction file. This matlab code won´t run without it. At least can you tell me what does this Y-junction do? I see the first parameter is a real number, the second is a vector of N_x elements, and the 3rd and 4th parameters are integers (number of steps along x-axis and z-axis, respectively).
From this information I can assume that the Y-junction evaluates some function for several points.
Once you provide the source code of the Y-junction, you will find an error in the 21st line: plot3(x,y,plotting(:,k),'.-,''LineWidth',1.0).
Here there is a sintaxis error. The right way for this line would be: plot3(x,y,plotting(:,k),'.-','LineWidth',1.0)
You inserted a comma inside the property '.-'
You must Check that.
If you fix this, you will not get any error. Fix it and see what you get.
Thank you for your response. I intend to construct a waveguide that branches to form a Y-shape (thus the term Y-junction). You can also have a look at the attached codes which are not running still. One is intended to construct the waveguiding structure and the other defines the Y-junction.
1. You must rename the file "y-junction.m". In the "plot_y.m" file, you call the function "y_junction", so this must be the file name, and not "y-function".
2. In the file "y-junction.m" (that now is "y_junction.m"), the output parameter "index" is never declared. Studying your code I assumed that "index" is actually "y". So, rename the output parameter "index" to "y".
That´s it.
Another thing: the file "wg_struct.m" is not required for "plot_y" to work.
Any way, I have attached the files with those changes. I´m not sure if that results are what you were expecting. I hope so.
Big thanks Luis, the code 'plot_y.m' is now ok as desired. I have re-named the file y_junction according to your advice but there is still an error in line 15 (>> y_junction
Error using y_junction (line 15)
Not enough input arguments.).
I have tried " y=zeros(z,x,N_x,N_z);" but still not ok. What could this be?