Search code examples
matlabmatlab-figurewaveformwave

How to plot 𝛽βˆ’𝑤 diagram in MATLAB?


I am trying to plot the π›½βˆ’π‘€ diagrams for the given phase constants using MATLAB, but although I have look at many web pages, there is not a similar example plotting π›½βˆ’π‘€ diagram in MATLAB. Could you please clarify me how to proceed by giving some examples regarding to this problem? Any help would really be appreciated.

Plot range: 𝑓=10π‘€β„Žπ‘§βˆ’10𝐺𝐻𝑧

w : Angular frequency

wc : A constant Angular frequency

Parameters for 1st: 𝑀𝑐1=0.2βˆ—π‘€, 𝑀𝑐2=0.4βˆ—π‘€, 𝑀𝑐3=0.6βˆ—π‘€, 𝑀𝑐4=0.8βˆ—π‘€ , Ι›1=1* Ι›0, ΞΌ= ΞΌ0

Parameters for 1st: a1=0.08636cm, a2=0.8636cm, a3=2.286cm, a4=29.21cm, Ι›1=1* Ι›0, ΞΌ= ΞΌ0

enter image description here


Solution

  • As the OP asked, this is a sort of Matlab code. I assume to map the plot of B with w in range [1,100] (but values can be changed) First case has wc has 3 different cases, 4 different plot of B (B1,B2, B3 and B4) will be mapped in four different colors

        %constant inizialization
        mu = 1.2566E-6;
        e = 1;
        start_f = 10000; %10 MHz start frequency range
        end_f = 10000000; %10 GHz end frequency range 
        step = 10 %plot the function every "step" Hz (ONLY INTEGER NUMBERS ALLOWED)
        k = 1;
        % function of B example: B = w*sqrt(mu*e)*sqrt(1-((wc^2)/w));
    
        %vectors initialization to avoid the "consider preallocation" Matlab not-critical warning
        range_f = ceil((end_f - start_f)/step) + 1;
        w = zeros(range_f);
        B1 = zeros(range_f);
        B2 = zeros(range_f);
        B3 = zeros(range_f);
        B4 = zeros(range_f);
    
        for i=start_f:step:end_f %from 10 MHz to 10 GHz with steps of 1 Hz
        %store i in the i-cell of vector w
          w(k) = i;
    %values that need to be updated every time
          w1 = 0.2*w(i);
          w2 = 0.4*w(i); 
          w3 = 0.6*w(i);
          w4 = 0.8*w(i); 
    %four different results of B
          B1(i) = w(i)*sqrt(mu*e)*sqrt(1-((w1^2)/w(i)));
          B2(i) = w(i)*sqrt(mu*e)*sqrt(1-((w2^2)/w(i)));
          B3(i) = w(i)*sqrt(mu*e)*sqrt(1-((w3^2)/w(i)));
          B4(i) = w(i)*sqrt(mu*e)*sqrt(1-((w4^2)/w(i)));
    
          k = k+1;
        end
    %plot the 4 lines    
        plot(w,B1,'r') %red line of B1 = f(w) 
        hold on
        plot(w,B2,'g') %green line of B2 = f(w) 
        hold on
        plot(w,B3,'b') %blue line of B3 = f(w) 
        hold on
        plot(w,B4,'k') %black line of B4 = f(w) 
    

    4 different cases have to be represented with 4 plot (in this example they have been overlayed).

    The last notation can be done in the same way (you have 4 constant parameters a1, a2 etc.) that does not depends from w this time. So

      B1a(i) = sqrt((w(i)^2)*mu*e - ((pi^2)/a1)));
      B2a(i) = sqrt((w(i)^2)*mu*e - ((pi^2)/a1)));
      B3a(i) = sqrt((w(i)^2)*mu*e - ((pi^2)/a1)));
      B4a(i) = sqrt((w(i)^2)*mu*e - ((pi^2)/a1)));
    

    If some errors (due to "fast" writing) occurs to you, report them in comments and I will correct and update the code