Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Read Qucs .dat file with Matlab #1021
    pault
    Participant

    A couple of tweaks from the octave version of the load data set program seems to work for matlab with the .opt variables included when trying the stub_filter.sch example:

    function [dataset] = loadQucsDataset(filename)

    pos = 0;
    dataset = [];

    fid = fopen(filename, “rb”);
    if fid < 0
    error(“Cannot open data file.”)
    return
    end

    if strcmp(fscanf(fid, “%8c”, 1), “QucsData”) == 0
    error(“File is not a Qucs data file.”)
    fclose(fid);
    return
    end

    version = fread(fid, 1, “int32”, 0, “ieee-le”);
    size = fread(fid, 1, “int32”, 0, “ieee-le”);

    % load header containing a list of all variables in the file
    header = fread(fid, size, “uchar”);

    type = 0;
    count = 0;
    index = 0;
    % search for the variable
    while index+9 <= size
    type = header(index+1) + 256*(header(index+2) + 256*(header(index+3) + 256*header(index+4)));
    count = header(index+5) + 256*(header(index+6) + 256*(header(index+7) + 256*header(index+8)));

    name = ”;
    dependency = ”;
    index = index + 9;
    while header(index) > 0
    name = strcat(name, char(header(index)));
    index = index + 1;
    end
    if bitget(type, 2) == 1 % is dependent variable?
    index = index + 1;
    while header(index) > 0
    dependency = strcat(dependency,char(header(index)));
    index = index + 1;
    end
    end

    if bitget(type, 3) == 0 % complex-valued numbers?
    data = fread(fid, 2*count, “double”, 0, “ieee-le”);
    data = data(1:2:2*count-1) + j*data(2:2:2*count);
    else
    data = fread(fid, count, “double”, 0, “ieee-le”);
    end

    pos = pos + 1;
    dataset(pos).name = name;
    dataset(pos).depName = dependency;
    dataset(pos).size = count;
    dataset(pos).type = type;
    dataset(pos).data = data;
    end

    fclose(fid);
    endfunction

    in reply to: Run circuit in the command line? #1015
    pault
    Participant

    I tried this in the QucsStudio window using octave with a single line. It didn’t work unless I put the whole thing in ‘ single quotes and you need to use ” double quotes around your paths if they have spaces in the names. To get the netlist I run the schematic and then it appears in the .qucs folder, you can also go to ->Simulation ->Show last netlist and then save it to the location of your choice.

    For example, this directly works for me, I pasted  it from my one line octave script which also works in matlab:

    dos(‘”C:\Temp\qucssim.exe” “C:\Temp\netlist.txt” “C:\Temp\datafile.dat”‘)

    the data in .dat are saved in a binary format which requires the use of the octave post processing scripts provided in the octave folder, a few tweaks are needed to use them in matlab due to how it opens the binary files.

     

     

    in reply to: RLCG transmission line model #921
    pault
    Participant

    Update: I was able to follow the code from QUCS to implement the complex impedance transmission line via Y parameters in the frequency domain device and it seems to work and give the expected loss. Schematic attached. I guess the RLCG model in QUCS is just doing this. The loss should be wiggly vs length because there are standing waves on the line and certain regions have more I^2R/unit length than others. The normal Tline does not know about this apparently and it seems to over or under estimates the loss.

    in reply to: Run circuit in the command line? #904
    pault
    Participant

    I am able to run from the command line using:

    qucssim.exe netlist.txt outputname.dat

    This also works from a dos() command in matlab in case you want to call the simulator to operate on the netlist.txt which you can get by copying the netlist it makes after running the schematic in the GUI and pasting it into a text file.

Viewing 4 posts - 1 through 4 (of 4 total)