Error using plot3 - Vectors must be the same lengths.
Afficher commentaires plus anciens
i had constructed a code to plot 3d graph between Electric Field and Magnetic Field
%Electric Field
AmpE = 4;
%Magnetic Field
AmpH = 2;
time = -1:0.01:1;
frequency = 97;
phase = 97;
phase_in_rad = degtorad(phase);
%Formula
E = AmpE*cos(2*pi*frequency*time+phase_in_rad);
H = AmpH*cos(2*pi*frequency*time+phase_in_rad);
end_limit=length(E);
x1 = E;
z1 = 1; end_limit;
y1 = zeros(1, end_limit);
y2 = H;
z2 = 1; end_limit;
x2 = zeros(1, end_limit);
plot3(z1,x1,y1);
hold on;
plot3(z2,x2,y2,'r');
hold off;
the problem is im getting error - "Vectors must be the same lengths".any ideas?
Réponses (1)
Azzi Abdelmalek
le 30 Avr 2014
Modifié(e) : Azzi Abdelmalek
le 30 Avr 2014
In your code there is an error with z1 and z2
z1 = 1;end_limit;
it should be
z1 = 1: end_limit;
and
z2= 1: end_limit;
1 commentaire
Aiman
le 30 Avr 2014
Catégories
En savoir plus sur Sources 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!