WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Patran File importieren

 

Infinitium
Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 29.04.13
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 15.08.2013, 14:13     Titel: Patran File importieren
  Antworten mit Zitat      
Hallo ihr Lieben

hat jemand hier schonmal ein PATRAN file in Matlab eingelesen? Wenn ja, wie seid ihr dabei genau vorgegangen? Bzw. hättet ihr noch den code und könntet ihn mir zur verfügung stellen, wäre echt sehr nett!

Liebe Grüße
Private Nachricht senden Benutzer-Profile anzeigen


BlackDread
Forum-Century

Forum-Century


Beiträge: 212
Anmeldedatum: 11.05.11
Wohnort: ---
Version: 2015a
     Beitrag Verfasst am: 15.08.2013, 14:59     Titel:
  Antworten mit Zitat      
Hallo Infinitium,

das Einlesen sollte nicht so das Problem sein, da PATRAN wohl auch ASCII-files exportieren kann(siehe unten).

Grüße
Chris

http://mathforum.org/kb/thread.jspa.....252&messageID=5963355

Zitat:

Hi,

use the Neutral File format (.out) to export data from Patran.

It's an ascii file format and you can specify data to export (nodes,
connectivity, and more...)

A brief introduction :
http://www.g-boege.de/english/makrosae/Manual/PATRAN.htm

See also the Patran documentation.

Use the low level functions FOPEN/FSCANF/FCLOSE in MATLAB to read the
OUT file.

=> http://www.mathworks.com/support/tech-notes/1600/1602.html

Jérôme
Private Nachricht senden Benutzer-Profile anzeigen
 
Infinitium
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 15
Anmeldedatum: 29.04.13
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 15.08.2013, 16:02     Titel:
  Antworten mit Zitat      
Hallo, danke für die schnelle Antwort. Ich habe das Problem bereits gelöst, falls noch jemand ein Patran File einlesen will hier der code:

einmal mithilfe von uiimport, achtung zum beispiel als txt Datei herausschreiben:

Code:

[filename, pathname] = uigetfile('*.txt' , 'getFile');
pfadload = strcat(pathname, filename);

uiimport(filename)
 



und hier noch das gescriptete:

Code:

%% Initialize variables.

[filename, pathname] = uigetfile('*.txt' , 'getFile');
filename = strcat(pathname, filename);

% filename = 'C:\Users\x115702\Desktop\Patran_reader\tra.txt';
delimiter = ' ';

%% Read columns of data as strings:
% For more information, see the TEXTSCAN documentation.
formatSpec = '%s%s%s%s%s%s%s%s%s%[^\n\r]';

%% Open the text file.
fileID = fopen(filename,'r');

%% Read columns of data according to format string.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true,  'ReturnOnError', false);

%% Close the text file.
fclose(fileID);

%% Convert the contents of columns containing numeric strings to numbers.
% Replace non-numeric strings with NaN.
raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
for col=1:length(dataArray)-1
    raw(1:length(dataArray{col}),col) = dataArray{col};
end
numericData = NaN(size(dataArray{1},1),size(dataArray,2));

for col=[1,2,3,4,5,6,7,8,9]
    % Converts strings in the input cell array to numbers. Replaced non-numeric
    % strings with NaN.
    rawData = dataArray{col};
    for row=1:size(rawData, 1);
        % Create a regular expression to detect and remove non-numeric prefixes and
        % suffixes.
        regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
        try
            result = regexp(rawData{row}, regexstr, 'names');
            numbers = result.numbers;
           
            % Detected commas in non-thousand locations.
            invalidThousandsSeparator = false;
            if any(numbers==',');
                thousandsRegExp = '^\d+?(\,\d{3})*\.{0,1}\d*$';
                if isempty(regexp(thousandsRegExp, ',', 'once'));
                    numbers = NaN;
                    invalidThousandsSeparator = true;
                end
            end
            % Convert numeric strings to numbers.
            if ~invalidThousandsSeparator;
                numbers = textscan(strrep(numbers, ',', ''), '%f');
                numericData(row, col) = numbers{1};
                raw{row, col} = numbers{1};
            end
        catch me
        end
    end
end


%% Replace non-numeric cells with NaN
R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),raw); % Find non-numeric cells
raw(R) = {NaN}; % Replace non-numeric cells

%% Create output variable
patran = cell2mat(raw);
%% Clear temporary variables
clearvars filename delimiter formatSpec fileID dataArray ans raw col numericData rawData row regexstr result numbers invalidThousandsSeparator thousandsRegExp me R;
 


Viel Spass beim einlesen Wink
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.