News: Contact us to upgrade your software!

Author Topic: Selecting Materials in MATLAB  (Read 21132 times)

cfriedland5

  • Client
  • **
  • Posts: 18
    •  
Selecting Materials in MATLAB
« on: August 05, 2013, 02:56:54 PM »
I am trying to automatically assign materials to groups in MATLAB, but am running into some difficulty. When retrieving VariableMaterial information, it appears to take the form of a vertical cell array with a blank first term, such as {''; '30028'; '30029';}. I try to write new materials in using lines like

    set(oGroup,'VariableMaterial',vpdTopFace_ThicknessMaterial,hmtIsotropic,MatKey)

in which MatKey takes the same vertical cell array form, with blank first time. However, when I try to set VariableMaterial, I get the error message:

    Error using Interface.3AAB542F_FE28_4B30_930E_D297246E0DB4/set
    Error: Type mismatch, argument 0


Ryan

  • Administrator
  • *****
  • Posts: 145
    •  
Re: Selecting Materials in MATLAB
« Reply #1 on: August 09, 2013, 07:54:17 AM »
The first first blank term is by design. I believe blank term was added so that a an array with zero materials can be passed back and forth.

http://hypersizer.com/help/index.php#COM/Members/com-group-variable_material.php

As far as passing MATLAB a string array to set the materials, I've been unable to get this to work. I think it's something with MATLAB not having strongly typed arrays or possibly a string vs. character array issue.

Your only workarounds at this point would be to set the materials using another programming environment or using stored group designs.

-Ryan

Neergaard

  • Client
  • **
  • Posts: 20
    •  
Re: Selecting Materials in MATLAB
« Reply #2 on: January 07, 2015, 02:33:35 PM »
Here is a less elegant approach to assigning materials families.  I have a limited and known set of aerospace alloys I am trying to transfer from an internal materials database into HyperSizer.

I use a GUI for materials input, so my variable names are a bit odd, but what follows is my code.

handles.inputdata.name = name;
 
switch (name)
    case {'Aluminum 2024', 'Aluminum 7075-T6'};
        handles.inputdata.MaterialFamily = 'Aluminum';
    case {'Stainless Steel 304 full hard', 'Maraging steel','A-286',...
            'Stainless Steel 316 quarter hard'
};
        handles.inputdata.MaterialFamily = 'Steel';
    case 'Narloy-Z'
        handles.inputdata.MaterialFamily = 'Copper';
    case {'Ti-6Al-4V', 'Ti 6Al 2Sn 4Zr 2Mo'}
        handles.inputdata.MaterialFamily = 'Titanium';
    case {'Inconel 718', 'Rene 41', 'Inconel 625', 'Haynes 230'}
        handles.inputdata.MaterialFamily = 'Heat-Resistant Alloys';
    otherwise
        handles.inputdata.MaterialFamily = 'Miscellaneous Isotropic';
end       

% Then, some time later

isotropic = hs.Isotropic.GetIsotropic('Al 2024'); %Identify existing material
isotropic.MaterialName = handles.inputdata.name;{1}% change the name

isotropic.MaterialFamily = handles.inputdata.MaterialFamily;


One could conceivably use parsing logic to automate a similar process for a larger group of materials.  For example, look for the string 'steel' anywhere in the material name (put that in the Steel material family), or look at the first two letters, putting Ti into the titanium material family, Mg or Ma in the magnesium material family (you would want to eliminate the steels by putting that case first, so Maraging steel doesn't end up in the Magnesium family)

-neergaard