How can I model a 2 port balun connected to an antenna in MATLAB - matlab

My goal is create an RF network in MATLAB using the antenna and RF toolboxes where I already have a 2:1 balun that has been fully characterized as a Touchstone file. I also have designed a loop antenna using the Antenna Toolbox and have produced successful S11 Return Loss graphs of the antenna by itself.
I need to find a way to connect the s-object (i.e. the balun) to the feed point of the antenna, and then re-run the simulation to get new S11 charts. Can anyone tell me how to do this with some brief code example? Many thanks!
P.S I am quite new to the antenna and RF toolboxes.

Related

Simscape Physical Signal: Why does is exist?

What is the added value of simscape physical signals compared to normal simulink signals? As far as I can see, from a functional perspective there is no difference between the two types of signals: I can add units to both types, they both have a direction of flow, and they both have similar function blocks like adding, substracting... Only for physical signals the available types of blocks is very limited. Why didn't the matlab guys just use normal simulink lines instead of the physical signals?
Physical signals, unlike Simulink signals, have units associated with them. This means that they follow a number of rules, for example to ensure that the right unit is used (e.g. you can't add kg and m/s). From the documentation:
Using the Physical Signal Ports
The following rules apply to Physical Signal ports:
You can connect Physical Signal ports to other Physical Signal ports with regular connection lines, similar to Simulink signal
connections. These connection lines carry physical signals between
Simscape blocks.
You can connect Physical Signal ports to Simulink ports through special converter blocks. Use the Simulink-PS Converter block to
connect Simulink outports to Physical Signal inports. Use the
PS-Simulink Converter block to connect Physical Signal outports to
Simulink inports.
Physical Signals can have units associated with them. Simscape block dialogs let you specify the units along with the parameter
values, where appropriate. Use the converter blocks to associate units
with an input signal and to specify the desired output signal units.
Any sensor block in Simscape (in whatever physical domain) will output a physical signal. You can then convert it into a normal Simulink for feed to your controller. Similarly, any source block in Simscape (in whatever physical domain) will take a physical signal as input.
I suggest you just read the Simscape product page
In particular,
Simscape components represent physical elements, such as pumps, motors, and op-amps. Lines in your model that connect these components correspond to physical connections in the real system that transmit power.
Accompanying that description is the following image, which shows how Simscape models can be far more intuitive to build than a model which uses standard signal. This means models are far more maintainable and clearer to, for example, engineers who may not have a comp-sci background.
Let's delve into what a "physical connection" is somewhat.
[Simscape] employs the Physical Network approach, which differs from the standard Simulink modeling approach and is particularly suited to simulating systems that consist of real physical components.
[ ... ]
Each system is represented as consisting of functional elements that interact with each other by exchanging energy through their ports.
You stated in your question that both methods have a flow direction. This is wrong!
Simscape blocks try and balance the energy between the inlet(s) and outlet(s). For instance a fixed orifice in a fluid system may have high pressure on one side. Simscape will try and solve the pressure balance each iteration. You would need some custom Simulink subsystem to achieve this if not for Simscape.
What is the added value of simscape physical signals compared to normal simulink signals?
What is it that you think Simscape physical signals provide? Is it one number? How do you solve a mass-spring-damper system with just position? It's position AND it's speed AND it's acceleration.
I can add units to both types
No you can't. You put whatever you want in Simulink. You don't get to choose anything about what's in the physical signal in Simscape. You can specify units in the blocks that the signals connect, but you don't get to pick what the pipe itself is carrying.
they both have a direction of flow
No they don't. Your head and your torso are connected. There's no directionality to this. They're just connected. The physical signal is likewise just showing that (things) are physically connected. Again, the mass-spring-damper system: If the damper points to the mass, and the spring points to the mass, then is there any possibility that the damper could affect the spring? Yes, of course. The damper affects the spring because the damper affects the mass and the mass affects the spring.
The spring affects the mass, and the mass affects the spring. The signal is bidirectional. You're confusing signal directionality with kinematic chains.
they both have similar function blocks like adding, substracting
If you're on a train that's going 30 mph, and you're walking forward at 3 mph, how fast are you going relative to the world frame? What if you're walking backward? There is a physical meaning in adding and subtracting physical signals.
[For] physical signals the available types of [function blocks are] very limited
What is it that you're thinking they're missing? Can you also provide a description of what the physical meaning of that function block would be?
Why didn't the matlab guys just use normal simulink lines instead of the physical signals?
Because they're not the same. The biggest point is probably that Simscape is signal + derivative + second derivative, but again they're just conceptually different. Simulink is an easy way to write code - do this step, move along the arrow, do the next step, etc. Simscape is a pictorial representation of a physical system. The physical signal lines just show that things are connected. The system gets solved simultaneously.
I don't think it's mainly about the enforcement of physical signal units, nice though this is.
I think it's about the solver - and before it gets to the solver, about the choice of states and equation causality - rearranging the equations ready to be solved.
Simulink doesn't have any truck with this and just gets straight on with integrating signals as a succession of samples. I know it gets complicated with variable step solvers, but they are only doing extra fancy numerical analysis with the sampled data. Integration and the here-and-now is what it's all about!
Simscape just starts with a bucket of variables and a bucket of equations that variously depend on said variables. A 'bipartite graph', I believe they call it.
Just as we have to navigate a route through simultaneous equations to pick off the simple ones and substitute (or the matrix equivalents of this) Simscape has to do likewise in software so wants to keep alive augmented info on signals like which equations they are in and whether it knows or can easily obtain their derivatives, what they are, etc. Physical signals behave for us users just like Simulink signals, but I reckon they are there to provide the valuable service to Simscape of keeping this augmented info alive and linked between blocks so that one massive matrix equation can be formed for the whole system, not separate ones that get sampled as Simulink systems between Simulink blocks.
This rearrangement of equations ready for the more conventional solver getting stuck in is a black art indeed! We learn very little of how Simscape does it from the MathWorks docs, but you can install OpenModelica for free and see how that does it.

Converter control simulation on simulink

I am struggling with a little project I decided to tackle. I am trying to replicate an example I found on a book using matlab simulink but I have no experience with simulink and control theory (I do understand the principles etc.).
The control block diagram is given but I do not understand some blocks and how to add my input (sine wave block on simulink)?
Here are the details:
Example I wish to reproduce
Schematic of the converter and desired control block diagram
If anyone could give me a little insight or direct me to some examples from which I could build on an understanding would be great!
Thank you in advance.
The portion entitled controller is the closed-loop feedback control for the system. K(s) would typically contain some type of PI control. In a more complicated control system, the structure of K(s) may be a little different, but will usually always contain an integration in order to ensure that the system eventually settles at the desired value.
The input Iref is your current command. In this case you would inject your sinusoid here which would produce a current waveform matching your desired output. If your desired output.
Output m is the modulating waveform produced by the controller. Everything inside the half-bridge converter section is a representation of the converter and everything that it is interfaced to (voltage sources).
The feedforward filter here is also a very important component. Since Vs contains an alternating waveform, the feed forward filter allows the system to respond to changes in Vs without relying on feedback compensation K(s). This helps to decouple current regulation from changes in voltage VD.
To start with the project, you can probably build the half bridge converter as shown. You can inject 400*cos(377t - pi/2) as VD.
For the feedback compensator K(s) you can feed the input into two gains (Ki and Kp) which you will select values for later. At the output of Ki insert an integrator (1/s) then sum the output of Kp and the integrator together.
For the feed-forward filter, you should probably just use a low pass filter with a gain of 1 at DC. The low pass filter prevents noise from entering the system. In this case you are running a simulation, so there will be no noise. However, the filter will eliminate any algebraic loops, which can cause warnings or errors in the simulation.
You can input your control signal at Iref.

Can neural network fail to learn a function? and How to choose better feature descriptors for pattern recognition?

I was working on webots which is an environment used to model, program and simulate mobile robots. Basically i have a small robot with a VGA camera, and it looks for simple blue coloured patterns on white walls of a small lego maze and moves accordingly
The method I used here was
​
Obtain images of the patterns from webots and save it in a location
in PC.
​​Detect the blue pattern, form a square enclosing the pattern
with atleast 2 edges of the pattern being part of the boundary of the
square.
​Resize it to 7x7 matrix(using nearest neighbour
interpolation algorithm)
The input to the network is nothing but the red pixel intensities of each of the 7x7 image(when i look at the blue pixel through a red filter it appears black so). The intensities of each pixel is extracted and the 7x7 matrix is then converted it to a 1D vector i.e 1x49 which is my input to the neural network. (I chose this characteristic as my input because it is 'relatively' less difficult to access this information using C and webots.​​)
I used MATLAB for this offline training method and I used a slower learning rate(0.06) to ensure parameter convergence and tested it on large and small datasets(1189 and 346 respectively). On all the numerous times I have tried, the network fails to classify the pattern.(it says the pattern belongs to all the 4 classes !!!! ) . There is nothing wrong with the program as I tested it out on the simpleclass_dataset in matlab and it works almost perfectly
Is it possible that the neural network fails to learn the function because of really poor data? (by poor data i mean that the datapoints corresponding to one sample of one class are very close to another sample belonging to a different class or something of that sort). Or can the neural network fail because of very poor feature descriptors?
Can anyone suggest a simpler method to extract features from the image(I am now shifting to MATLAB as I am now only concerned with simulations in webots and not the real robot). What sort of features can I choose? The patterns are very simple (L,an inverted L and its reflected versions are the 4 patterns)
Neural networks CAN fail to learn a function; this is most often caused by employing a network topology which is too simple to model the necessary function. A classic example of this case is attempting to learn an XOR function using a perceptron classifier, although it can even happen in multilayer neural nets sometimes; especially for complex tasks like image recognition. See my previous answer for a rough guide on how to select neural network parameters (ignore the convolution stuff if you want, although I would highly recommened looking into convolutional neural networks if you are still having problems).
It is a possiblity that there is too little seperability between classes, although I doubt that this is the case given your current features. Is there a reason that your network needs to allow an image to be four classifications simultaneously? If not, then perhaps you could classify the input as the output with the highest activation instead of all those with high activations.

Matlab Neural Network Advice

I am working currently on a project to optimize heater performance using MATLAB neural network tool, I read the manuals and got the guidance from MATLAB manual.
I have configured the network and tested it, what I need is two points:
1. Am I on the right track? is my network correct? I need an expert advise
2. I need to (Optimize) the performance of the heater, I have defined my function but I don't have a clue how to integrate the network in the optimization of the function.
my network is as follows
3 inputs x1 x2 x3
one out put
load input1
load input2
load input3
x1= importdata('input1.txt'); (similar the other inputs and output)
[x1n,x1min,x1max]=norm_nn(x1); ( I worte my own normalization function)
IN=[x1n x2n x3n]';
OUT=[y1n]';
INTRAIN = IN(:,1:1307);
OUTTRAIN = OUT(:,1:1307);
INTEST =IN(:,1308 : 1634);
OUTTEST = OUT(:,1308:1634);
NETWORKNet1 = newff(IN,OUT,[20 20 20], {'tansig' 'tansig' }, 'trainbr');
net = init (NETWORKNet1);
NETWORKNet1 = trainbr(NETWORKNet1,INTRAIN,OUTTRAIN);
YtestNwt1 = sim(NETWORKNet1,INTEST);
y1testd=denorm_nn7(YtestNet1(1,:),y1min,y1max);
e1=er8(y1testd,y1(1308:1634));
save Net1
I have used (1634 data points and divided it for training (80%) and test (20%))
Here is some advice:
(A) Use feedforwardnet as newff is deprecated
(B) Plot the training, test data and the network result to make it easier to visualize what's going on.
(C) By writing [20 20 20] your network has 3 hidden layers. The vast majority of problems require only 1 hidden layer. Only if all other avenues have been exhausted should you move to multiple hidden layers.
(D) Test the network (ie, the sim command) on the training data first. This is an 'easy' test for a neural network and should be working first before you move on. Then you can test it with the test data (which the network was not trained on). This will show if the network has generalized the shape of the data it is trying to learn.
Validation is also another important factor which helps the network to generalize. If you look at the matlab neural network training window (nntraintool) and click 'performance', one of the graphs should be labelled 'validation'.
Regarding your specific questions:
1. Is my network correct? - difficult to say without seeing the dataset.
2. Optimizing performance of the heater - on a simple level you would have a single output neuron, a number between 0 and 1 which denotes heater performance. The input neurons then contain any other parameters involved.
But now, the network can only predict what the performance will be, given any combination of inputs. It won't be able to tell you which inputs will give you maxmimum output. For only 3 inputs, with low resolution / granularity, you could try an exhaustive / brute force search. Otherwise, look into genetic algorithms to quickly find a good solution.

Find class probabilities in matlab PNN and make ROC plot

I have a Probablistic Neural Network classification experiment set up in MATLAB. I can get the classes for unseen data using the sim command. Is there any way I can get the probabilities for the classes that the classifier calculates? Also, is there any direct way to plot the Reciever Operating Characterstic curve and calculate the Area Under the ROC for my classifier?
if you have the Statistics Toolbox, you can use perfcurve function added in recent versions of MATLAB to plot ROC curves and get AUC.
You may have better luck getting a response if you include a little more background and define your terms. I recognize ROC as receiver operating characteristic curve, but PNN and AUC are just alphabet soup to me. Don't make the mistake of assuming that someone outside of your very specific problem domain cannot help you. You have to build a bit of a language bridge by explaining your jargon first, though. This has the added advantage of making this particular question more useful to the stackoverflow community at large when it is eventually answered.