STAR-DELTA TRANSFORMATION IN MATLAB AND C PROGRAMMING
Here is a simple a program written in MatLab and C programming to transform Resistance from Delta to Star and vice versa.
The C program can also find the equivalent resistance of resistors in series and parallel.
Browse to where your m files are located in the current directory you can use cd command, in my case it was saved at the directory "c:\users\Zakaria\Documents\Matlab\blog" .
The C program can also find the equivalent resistance of resistors in series and parallel.
MATLAB
.m file for delta2star
function[soln]=delta2star(R_ab,R_bc,R_ac)
R_a=(R_ab*R_ac)/(R_ab+R_bc+R_ac);
R_b=(R_ab*R_bc)/(R_ab+R_bc+R_ac);
R_c=(R_bc*R_ac)/(R_ab+R_bc+R_ac);
fprintf('delta values \t Star values\n ')
fprintf('R_ab=%.2f \t R_a=%.2f \n',R_ab,R_a);
fprintf('R_bc=%.2f \t R_b=%.2f \n',R_bc,R_b);
fprintf('R_ac=%.2f \t R_c=%.2f \n',R_ac,R_c);
soln=[R_a;R_b;R_c];
end
|
.m file for star2delta
function [Soln] = star2delta(R_a,R_b,R_c)
R_ab = R_a + R_b + (R_a*R_b)/R_c;
R_bc = R_b + R_c + (R_b*R_c)/R_a;
R_ac = R_a + R_c + (R_a*R_c)/R_b;
fprintf('delta values \t Star values \n')
fprintf('R_a=%.2f \t R_ab=%.2f \n',R_a,R_ab)
fprintf('R_b=%.2f \t R_bc=%.2f \n',R_b,R_bc)
fprintf('R_c=%.2f \t R_ac=%.2f \n',R_c,R_ac)
Soln=[R_ab;R_bc;R_ac];
end
|
output
C PROGRAM
Also included in the c program, can calculate Resistors in series and parallel
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Parallel_Series(); //declare series and parallel conversion function
void Star_Delta_xform(); //declare series and parallel conversion function
int input;
int main()
{
do
{
printf("__________________________\n");
printf("Select Conversion:\n");
printf("__________________________\n");
printf("1. Equivalent resistance of Parallel connection\n");
printf("2. Equivalent resistance of Series connection\n");
printf("3. Star Delta Transformation\n");
printf("4. Exit\n");
printf("Select: ");
scanf("%d",&input);
if (input == 1 || input == 2)
{
Parallel_Series();
}
else if(input == 3)
{
Star_Delta_xform();
}
else
{
printf("Wrong Selection! Try Again\n");
}
}
while(input != 4);
return 0;
}
void Parallel_Series()
{
int num,cnt;
float R[100],R_t,result=0;
char str1[9]="Parallel";
char str2[8]="Series";
if (input==2)
{
//copy string 2 to 1 to display series instead of parallel
strcpy(str1,str2);
}
printf("How many number of Resistors are in %s: ",str1);
scanf("%d",&num);
printf("Enter Value for: \n");
for(cnt=0; cnt!=num; cnt++)
{
printf("%s R_%d=",str1,cnt+1);
scanf("%f",&R[cnt]);
//for parallel
if (input==1)
{
result += 1/R[cnt];
R_t = 1/result;
}
else
{
R_t += R[cnt];
}
}
printf("Equivalent resistance of %d resistors in %s is %.2f Ohms\n",num,str1,R_t);
}
void Star_Delta_xform()
{
float R_a=0,R_b=0,R_c=0,R_ab,R_bc,R_ac;
int select;
printf("Select transformation\n----------------------\n");
printf("1. Star --> Delta\n");
printf("2. Delta --> Star\n");
printf("Select: ");
scanf("%d",&select);
switch(select)
{
case 1:
{
printf("1. enter the value of the Star connected resistors:\n");
printf("R_a = ");
scanf("%f",&R_a);
printf("R_b = ");
scanf("%f",&R_b);
printf("R_c = ");
scanf("%f",&R_c);
R_ab=R_a+R_b+(R_a*R_b)/R_c;
R_bc=R_b+R_c+(R_b*R_c)/R_a;
R_ac=R_a+R_c+(R_a*R_c)/R_b;
printf("the equivalent Delta config. is: \n");
printf("R_ab = %.2f Ohms\n",R_ab);
printf("R_bc = %.2f Ohms\n",R_bc);
printf("R_ac = %.2f Ohms\n",R_ac);
break;
}
case 2:
{
printf("1. enter the values of the Delta connected resistors:\n");
printf("R_ab = ");
scanf("%f",&R_ab);
printf("R_bc = ");
scanf("%f",&R_bc);
printf("R_ac = ");
scanf("%f",&R_ac);
R_a = (R_ab*R_ac)/(R_ab + R_bc + R_ac);
R_b = (R_ab*R_bc)/(R_ab + R_bc + R_ac);
R_c = (R_ac*R_bc)/(R_ab + R_bc + R_ac);
printf("the equivalent Star config. is: \n");
printf("R_a = %.2f Ohms\n",R_a);
printf("R_b = %.2f Ohms\n",R_b);
printf("R_c = %.2f Ohms\n",R_c);
break;
}
}
}
|
output
STAR-DELTA TRANSFORMATION IN MATLAB AND C PROGRAMMING
Reviewed by
Zakaria Mohammed
on
October 10, 2015
Rating:
No comments :