From 514ca92c9bee390884287675faa82797dc0e3012 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Frakn=C3=B3i=20Tam=C3=A1s?= <fraknoitamas@gmail.com>
Date: Fri, 12 Jun 2020 21:20:43 +0200
Subject: [PATCH] plot fixes

---
 RTX class/BalazsAperture.m    |  3 +++
 RTX class/FarField.m          |  3 ++-
 RTX class/SegmentedAperture.m | 15 +++++++++++----
 RTX class/rtx_test.m          | 12 ++++++------
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/RTX class/BalazsAperture.m b/RTX class/BalazsAperture.m
index b8ccb7b..3384ce1 100644
--- a/RTX class/BalazsAperture.m	
+++ b/RTX class/BalazsAperture.m	
@@ -29,7 +29,10 @@ classdef BalazsAperture < Aperture
             histogram = obj.getCollisionHistogram();
             figure;            
             x = linspace(-obj.size/2, obj.size/2, length(histogram));
+            subplot(2,1,1);
             plot(x, abs(histogram));
+            subplot(2,1,2);
+            plot(x, angle(histogram));
             title("Apertúrán áthaladó sugarak eloszlása");
             xlabel("Pozíció");
             ylabel("Sugarak száma");
diff --git a/RTX class/FarField.m b/RTX class/FarField.m
index cf39a5c..60b5d9f 100644
--- a/RTX class/FarField.m	
+++ b/RTX class/FarField.m	
@@ -84,11 +84,12 @@ classdef FarField < handle
             end
             figure;
             y = abs(obj.field);
-            %y = y/max(y);
+            y = y/max(y);
             plot(obj.theta*180/pi, 20*log10(y));
             title("Távoltér");
             xlabel("\Theta [°]");
             ylabel("S [dB]");
+            ylim([-40 0]);
         end
         
         function beamWidth = getBeamWidth(obj)
diff --git a/RTX class/SegmentedAperture.m b/RTX class/SegmentedAperture.m
index 14a6106..c17dde1 100644
--- a/RTX class/SegmentedAperture.m	
+++ b/RTX class/SegmentedAperture.m	
@@ -18,7 +18,7 @@ classdef SegmentedAperture < Aperture
                 if length(trace.rays) == length(obj.prevTrace.rays)
                     segmentSize = abs(obj.prevCol.pos.y - col.pos.y);
                     obj.segments.add(Segment(obj.prevCol.pos.y, col.pos.y, ...
-                        trace.complexAmplitude/segmentSize * exp(1i*mod(trace.length, trace.wavelength))));
+                        trace.complexAmplitude/segmentSize * exp(1i*2*pi*mod(trace.length, trace.wavelength)/trace.wavelength)));
                 end
             end
             obj.prevTrace = trace;
@@ -37,9 +37,16 @@ classdef SegmentedAperture < Aperture
             [histogram,x1, x2] = obj.getCollisionHistogram();
             plot(0, 0);
             hold on;
-            for k = 1:length(histogram)
-                plot([x1(k) x2(k)], [abs(histogram(k)), abs(histogram(k))],'b');
-            end
+%             for k = 1:length(histogram)
+%                 plot([x1(k) x2(k)], [abs(histogram(k)), abs(histogram(k))],'b');
+%             end
+            x = [x1; x2];
+            h = [histogram; histogram];
+            subplot(2,1,1);
+            plot(x(:), abs(h(:)));
+            subplot(2,1,2);
+            plot(x(:), angle(h(:)));
+            %plot(x(:), h(:), 'b');
             hold off;
         end
     end
diff --git a/RTX class/rtx_test.m b/RTX class/rtx_test.m
index 50ce76d..0cdb737 100644
--- a/RTX class/rtx_test.m	
+++ b/RTX class/rtx_test.m	
@@ -1,15 +1,15 @@
-%clear
-%close all
+clear
+close all
 
 reflectors = [PlaneReflector([2 0], 2), ParabolaReflector([0 0], 4, 3)];
 %reflectors = [PlaneReflector([-1 1], 0)];
-aperture = BalazsAperture([3 0], 20, 400);
+aperture = BalazsAperture([3 0], 20, 1000);
 aperture2 = SegmentedAperture([3 0], 20);
-antenna = Antenna(Vect(1,0), [ones(1,125), zeros(1,750), ones(1,125)], zeros(1,1000));
-%antenna = Antenna(Vect(1,0));
+antenna = Antenna(Vect(1,0), [ones(1,1250), zeros(1,7500), ones(1,1250)], zeros(1,10000));
+% antenna = Antenna(Vect(1,0), ones(1,10000), zeros(1,10000));
 wavelength = 3e8/1e9;
 nRay = 10000;
-nRay2 = 1000;
+nRay2 = 2000;
 
 rtx = RTX(reflectors, aperture, antenna, wavelength, nRay);
 rtx.trace();
-- 
GitLab