how can I solve the problem with the plot function? (every vectors' length should be the same)
    3 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
clear, close all, clc
%% Calculation of Ey and Ez from V
%% Inputs
% Source Info:
Qs = 10e-9;
zs1= -1;
zs2 = 1;
Ns = 200; % No. of sections
% Field points Info (Qt = 1 C assumed)
%y0 = 0.5;
%zf0 = 0.5;
%% Grid of field points
zf1 = -5;
zf2 = 5;
dzf = 0.01;
yf1 = 0.2;
yf2 = 0.8;
dyf = 0.01;
%%
L = zs2-zs1;
rhoL = Qs/L;
dzs = (zs2-zs1)/Ns;
zzs = zs1+0.5*dzs+(0:Ns-1)*dzs;
dq = rhoL*dzs;
yyf = yf1:dyf:yf2;  % Field points along y
zzf = zf1:dzf:zf2;  % Field points along z
choice = 1;
if choice == 1
    Nf = length(yyf);
else 
    Nf = length(zzf);
end
for ii=1:Nf
    yf = yyf(ii);
    choice = 0;
    for jj=1:Nf
        zf = zzf(jj);
        rv1 = [0 yf-dyf/2 zf-dzf/2];  % -->V1
        for kk=1:Ns
            zs = zzs(kk);
            rsv = [0 0 zs];
            dV(kk) = func_V(rv1,rsv,dq);
        end
        V1 = sum(dV);
        rv2 = [0 yf+dyf/2 zf+dzf/2];  % -->V2
        for kk=1:Ns
            zs = zzs(kk);
            rsv = [0 0 zs];
            dV(kk) = func_V(rv2,rsv,dq);
        end
        V2 = sum(dV);
        V(ii,jj) = (V1+V2)/2;
        theta = atan(dyf/dzf);
        Ey(ii,jj) = -(V2-V1)/sqrt(dyf^2+dzf^2)*sin(theta);
        Ez(ii,jj) = -(V2-V1)/sqrt(dyf^2+dzf^2)*cos(theta);
    end
end
subplot(2,1,1), plot(yyf,zzf,V)
xlabel('y (m)'), ylabel('z (m)'), zlabel('V (V)')
subplot(2,1,2), plot(yyf,zzf,Ez)
xlabel('y (m)'), ylabel('z (m)'), zlabel(Ez (V/m)')
1 Commento
  Dyuman Joshi
      
      
 il 9 Apr 2023
				yyf is 1x61, zzf is 1x1001 and V and Ez are 61x61.
Theoretically, how do you plan to plot these?
Risposte (1)
  Vanshika Vaishnav
    
 il 12 Apr 2023
        As the dimensions of the variables are not same (i.e.yyf is 1x61, zzf is 1x1001 and V and Ez are 61x61). It is not possible to plot them in same length. 
"plot3" can be used to plot all this variables in vector or same length:
- To plot a set of coordinates connected by line segments, specify X, Y, and Z as vectors of the same length.
- To plot multiple sets of coordinates on the same set of axes, specify at least one of X, Y, or Z as a matrix and the others as vectors.
for more information refer this documentation:
0 Commenti
Vedere anche
Categorie
				Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


