Matrix dimensions must agree
Afficher commentaires plus anciens
Hi, I'm trying to plot a field, but it always shows me the next error:
Matrix dimensions must agree.
Error in codeH (line 24)
Hx = (((1j .* k .* a.^2 .* I0 .* cos(theta)) ./ (x.^2+(z-b).^2)) .* (1 + 1 ./ (1j .*
k .* sqrt(x.^2+(z-b).^2))) .* exp(-1j .* k .* sqrt(x.^2+(z-b).^2))) .*
sin(theta).*cos(phi);
The code that I'm using is this:
clear all
close all
clc
a = 0.4;
f = 10^6;
w = 2 .* pi .* f;
I0 = 1;
b = (0.4/2);
mu0 = 4 * pi * 1e-7;
e0 = 8.85e-12;
k = w .* sqrt( mu0 .* e0 );
theta = (-pi/2:pi/3:pi/2);
phi = (0:pi/2:2*pi);
xx = linspace(-1,0.1,1);
zz = xx;
[x,z] = meshgrid(xx,zz);
Hx = (((1j .* k .* a.^2 .* I0 .* cos(theta)) ./ (x.^2+(z-b).^2)) .* (1 + 1 ./ (1j .* k .* sqrt(x.^2+(z-b).^2))) .* exp(-1j .* k .* sqrt(x.^2+(z-b).^2))) .* sin(theta).*cos(phi);
Hz = (((1j .* k .* a.^2 .* I0 .* cos(theta)) ./ (x.^2+(z-b).^2)) .* (1 + 1 ./ (1j .* k .* sqrt(x.^2+(z-b).^2))) .* exp(-1j .* k .* sqrt(x.^2+(z-b).^2))) .* cos(theta);
quiver(x,z,abs(Hx),abs(Hz))
I'm kind of desperate right now
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!