How do I change the default type of an Inport block?

Discussion in 'MATLAB' started by Masood Sadiq, Jan 14, 2009.

  1. Masood Sadiq

    Masood Sadiq Guest

    Hello...

    How do I change the default type of an Inport block? I tried to use the 'set_param' command to change the type to 'int32', but I get an error message saying:
    ----
    "??? Error using ==> set_param
    Inport block parameter 'Type' is read-only."
    ----
    This is consistent with what the Help page says, but surely the type of a block can be changed.

    Please see the set_param' command in the last line of the 'for' loop below. Feel free to run the script if you wish.
    -----------------
    open_system(new_system('modelname'))

    InputList= {'Input1','Input2','Input3','Input4','Input5',...
    'Input6','Input7','Input8','Input9','Input10'};

    OutputList={'Output1','Output2','Output3','Output4','Output5',...
    'Output6','Output7','Output8','Output9','Output10'};

    for i = 1:10
    InString = ['modelname/',char(InputList(i))];
    OutString = ['modelname/',char(OutputList(i))];
    PortNumber = ['/',num2str(i)];

    add_block('built-in/Inport', InString , 'Position', [20 55.*(i) 60 55.*(i)+10]);
    add_block('built-in/Outport', OutString, 'Position',[400 55.*(i) 440 55.*(i)+10]);

    % Get handle (h) as output
    h = add_line('modelname',[char(InputList(i)),'/1'],[char(OutputList(i)),'/1']);
    % Assign name to signal
    set_param(h,'Name',['Signal #' num2str(i)]);

    % Define input types:
    set_param(InString, 'Type', 'int32');

    end
    save_system('modelname');
     
    Masood Sadiq, Jan 14, 2009
    #1
    1. Advertisements

  2. Masood Sadiq

    Praetorian Guest

    Masood,
    You're trying to set the Simulink object type parameter which, as
    you've discovered, is read-only. Change the set_param line to:

    set_param(InString, 'DataType', 'int32');

    HTH,
    Ashish.
     
    Praetorian, Jan 14, 2009
    #2
    1. Advertisements

  3. Masood Sadiq

    Masood Sadiq Guest

    Masood,
     
    Masood Sadiq, Jan 15, 2009
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.