Filter löschen
Filter löschen

Subscripted assignment dimension mismatch.Error in fnc (line 12) matrix1(1,​1)=cos(k*d​elta_z);ma​trix1(1,2)​=(i/q)*sin​(k*delta_z​);

1 Ansicht (letzte 30 Tage)
i tried to form an matrice and took this error. here is my code.
function [matrix1,matrix2] = fnc(delta_z,w);
my aim is to form a matrix like the one in an image and for different layers and multiply them with another matrices. do you suggest any thing? best regards..

Akzeptierte Antwort

Michelangelo Ricciulli
Michelangelo Ricciulli am 31 Mär. 2018
Hi, Before answering the question, I want to give you a couple of suggestions.
First, try to post your code in better format. It is really hard to read (put the code in "code" style, and try to use one instruction per row).
Second, if you try your code one instruction at a time, it's much easier to find where the error is located. Or, even better, put your code in a script/function file and then try to execute it. Matlab will give you details about where the error is found. (Error in eren_baris (line 7) k=N_a(w/3e8);)
Let's answer your question now. You wrote
but probably, you wanted
Without the multiplication, matlab is interpreting w/3e8 as an index for N_a. But w/3e8 is not an integer, and thus can't be an index. Moreover, in this case, N_a is not even a vector.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by