how to parse text file read into cell array
I’m trying to programmatically update a Qspice netlist. I read the *.net file in using fileread.
netlist = fileread([filepath filename);
the file looks like this:
‘* netlist
L5 N08 0 {Lp} Rser = 0.01 ic=0
L6 0 N07 {Ls} Rser=0.01 ic=0
C3 N06 N08 {Cp}
C4 N07 N09 {Cs}
V2 N06 0 pulse -VGA VGA 0 3n 3n period/2 period ac=1
R1 N09 0 .01
L1 N11 0 {Lp} Rser = 0.01 ic=0
L2 0 N10 {Ls} Rser=0.01 ic=0
C1 N05 N11 {Cp}
C2 N10 N12 {Cs}
V1 N05 0 pulse -VGA VGA 0 3n 3n period/2 period
R2 N12 0 5
.tran 0 {duration} {starttran} 2n
.param fres1=83000
.param period= 1/fsw
.param Cp = 1/(Lp*(2*pi*fres1)^2)
.param Lp= 34µ
.param Ls= 34µ
.param Cp2 = Cp*2
.param Idc = 104.42
.
.param Vbat = 400
.param RL = Vbat/Idc
.param Rac = 8/pi^2*RL
.param Cs2 = Cs*2
.param Cs = 1/(Ls*(2*pi*fres2)^2)
k1 L5 L6 {kcoup}
.param duration =20m
.param starttran = duration-4m
.param VGA =40
.param kcoup=0.2
.param fres2=85000
.save I(L5) I(L6) v(n05) i(L1) i(R2)
k2 L1 L2 {kcoup}
.param startfreq = 82000
.param stopfreq = 87000
.param stepfreq = 50
.step param fsw list 81750 83000 85000 86400
.end
‘
I want to programmatically replace the .step param line with a new one, as a loop through my code and update some of these parameters. ‘
I can find the index into the char array where ".step param", but I can’t figure out how to convert the characters from .step to the end of that line to a string so I can just replace the whole line with a new one.
Thanks in advance for the help.I’m trying to programmatically update a Qspice netlist. I read the *.net file in using fileread.
netlist = fileread([filepath filename);
the file looks like this:
‘* netlist
L5 N08 0 {Lp} Rser = 0.01 ic=0
L6 0 N07 {Ls} Rser=0.01 ic=0
C3 N06 N08 {Cp}
C4 N07 N09 {Cs}
V2 N06 0 pulse -VGA VGA 0 3n 3n period/2 period ac=1
R1 N09 0 .01
L1 N11 0 {Lp} Rser = 0.01 ic=0
L2 0 N10 {Ls} Rser=0.01 ic=0
C1 N05 N11 {Cp}
C2 N10 N12 {Cs}
V1 N05 0 pulse -VGA VGA 0 3n 3n period/2 period
R2 N12 0 5
.tran 0 {duration} {starttran} 2n
.param fres1=83000
.param period= 1/fsw
.param Cp = 1/(Lp*(2*pi*fres1)^2)
.param Lp= 34µ
.param Ls= 34µ
.param Cp2 = Cp*2
.param Idc = 104.42
.
.param Vbat = 400
.param RL = Vbat/Idc
.param Rac = 8/pi^2*RL
.param Cs2 = Cs*2
.param Cs = 1/(Ls*(2*pi*fres2)^2)
k1 L5 L6 {kcoup}
.param duration =20m
.param starttran = duration-4m
.param VGA =40
.param kcoup=0.2
.param fres2=85000
.save I(L5) I(L6) v(n05) i(L1) i(R2)
k2 L1 L2 {kcoup}
.param startfreq = 82000
.param stopfreq = 87000
.param stepfreq = 50
.step param fsw list 81750 83000 85000 86400
.end
‘
I want to programmatically replace the .step param line with a new one, as a loop through my code and update some of these parameters. ‘
I can find the index into the char array where ".step param", but I can’t figure out how to convert the characters from .step to the end of that line to a string so I can just replace the whole line with a new one.
Thanks in advance for the help. I’m trying to programmatically update a Qspice netlist. I read the *.net file in using fileread.
netlist = fileread([filepath filename);
the file looks like this:
‘* netlist
L5 N08 0 {Lp} Rser = 0.01 ic=0
L6 0 N07 {Ls} Rser=0.01 ic=0
C3 N06 N08 {Cp}
C4 N07 N09 {Cs}
V2 N06 0 pulse -VGA VGA 0 3n 3n period/2 period ac=1
R1 N09 0 .01
L1 N11 0 {Lp} Rser = 0.01 ic=0
L2 0 N10 {Ls} Rser=0.01 ic=0
C1 N05 N11 {Cp}
C2 N10 N12 {Cs}
V1 N05 0 pulse -VGA VGA 0 3n 3n period/2 period
R2 N12 0 5
.tran 0 {duration} {starttran} 2n
.param fres1=83000
.param period= 1/fsw
.param Cp = 1/(Lp*(2*pi*fres1)^2)
.param Lp= 34µ
.param Ls= 34µ
.param Cp2 = Cp*2
.param Idc = 104.42
.
.param Vbat = 400
.param RL = Vbat/Idc
.param Rac = 8/pi^2*RL
.param Cs2 = Cs*2
.param Cs = 1/(Ls*(2*pi*fres2)^2)
k1 L5 L6 {kcoup}
.param duration =20m
.param starttran = duration-4m
.param VGA =40
.param kcoup=0.2
.param fres2=85000
.save I(L5) I(L6) v(n05) i(L1) i(R2)
k2 L1 L2 {kcoup}
.param startfreq = 82000
.param stopfreq = 87000
.param stepfreq = 50
.step param fsw list 81750 83000 85000 86400
.end
‘
I want to programmatically replace the .step param line with a new one, as a loop through my code and update some of these parameters. ‘
I can find the index into the char array where ".step param", but I can’t figure out how to convert the characters from .step to the end of that line to a string so I can just replace the whole line with a new one.
Thanks in advance for the help. char arrays, indexing MATLAB Answers — New Questions