Why my generated matrix has a square bracket at every line?

My generated matrix has a square bracket at every line, why? How to solve this problem? Many thanks! The codes are as follows.
clear all;
syms kz x y
x=0.5;
y=0;
m = 2;
vh = 4;
mu = 11;
delta = 8;
HBAR = 1.05457266e-34;
ME = 9.1093897e-31;
ELEC = 1.60217733e-19;
Kh = 2.106;
vKh = [0,0,0;Kh,0,0;-Kh,0,0;0,Kh,0;0,-Kh,0];
kc = sqrt(2*ME*ELEC/HBAR^2)*1e-10;
ku = kc*sqrt(mu+delta);
kd = kc*sqrt(mu-delta);
a3 = [pi/Kh,pi/Kh,sqrt(2)*pi/Kh];
kuu =@(x,y) [-ku*sin(x)*cos(y), -ku*sin(x)*sin(y), kz];
n=0:m;
for p=1:5;
for q=1:5;
tuu(p,q)=(sum((kuu(x,y) + vKh(p,:)).^2)-ku^2)*(p==q)+ kc^2*vh*sum(exp(i*n*sum((vKh(q,:)-vKh(p,:)).*a3)))*(p~=q);
end
end
tuu

Respuestas (2)

Steven Lord
Steven Lord el 31 de Ag. de 2018
That's just the way non-scalar symbolic matrices are displayed in the Command Window.
The Live Editor displays symbolic matrices differently. Perhaps that will be more to your liking. See this example that creates and manipulates symbolic matrices. The Linear Algebra section of that example in particular creates matrices b and lambda.
KALYAN ACHARJYA
KALYAN ACHARJYA el 31 de Ag. de 2018
Editada: KALYAN ACHARJYA el 31 de Ag. de 2018
kuu =@(x,y) -ku*sin(x)*cos(y), -ku*sin(x)*sin(y), kz;

5 comentarios

@ KALYAN ACHARJYA Why I have the error"kuu include the function_handle"?
KALYAN ACHARJYA
KALYAN ACHARJYA el 1 de Sept. de 2018
Editada: KALYAN ACHARJYA el 1 de Sept. de 2018
%Copy paste and check
clc;
clear all;
close all;
syms kz x y
x=0.5;
y=0;
m=2;
vh=4;
mu=11;
delta=8;
HBAR=1.05457266e-34;
ME=9.1093897e-31;
ELEC=1.60217733e-19;
Kh=2.106;
vKh=[0,0,0;Kh,0,0;-Kh,0,0;0,Kh,0;0,-Kh,0];
kc=sqrt(2*ME*ELEC/HBAR^2)*1e-10;
ku=kc*sqrt(mu+delta);
kd=kc*sqrt(mu-delta);
a3=[pi/Kh,pi/Kh,sqrt(2)*pi/Kh];
kuu =@(x,y) -ku*sin(x)*cos(y), -ku*sin(x)*sin(y), kz;
n=0:m;
for p=1:5;
for q=1:5;
tuu(p,q)=(sum((kuu(x,y) + vKh(p,:)).^2)-ku^2)*(p==q)+ kc^2*vh*sum(exp(i*n*sum((vKh(q,:)-vKh(p,:)).*a3)))*(p~=q);
end
end
tuu
@KALYAN ACHARJYA Thank you very much! Although I obtain the tuu, there still appears the same error. Is it better I define a numerical matrix tuu1=double(tuu)?
KALYAN ACHARJYA
KALYAN ACHARJYA el 1 de Sept. de 2018
Editada: KALYAN ACHARJYA el 1 de Sept. de 2018
@Henan My Pleasure OK
@KALYAN ACHARJYA I have voted your answer. Thanks again!

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 31 de Ag. de 2018

Comentada:

el 2 de Sept. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by