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

Druckverteilungsdaten aus (*.asf bzw. txt) importieren

 

Toniblabla
Forum-Newbie

Forum-Newbie


Beiträge: 3
Anmeldedatum: 06.11.14
Wohnort: ---
Version: Matlab 2014b
     Beitrag Verfasst am: 06.11.2014, 23:05     Titel: Druckverteilungsdaten aus (*.asf bzw. txt) importieren
  Antworten mit Zitat      
Vielleicht kann mir jemand helfen?!
Ich will Druckverteilungsdaten von Tekscan in *.asf Format in Matlab einlesen, jedoch gibts immer den Fehler:
SWITCH expression must be a scalar or string constant.

Error in read_txt_tekscan (line 77)
switch parameters_temp

Error in preprocess_tekscandata (line 55)
[TSmtrx, TKS, TEKSCAN_INFO]=read_txt_tekscan(filename);

TSmtrx und TEKSCAN_INFO werden berechnet, nur TKS nicht

Code:

[FileName,PathName,~]=uigetfile('*.asf','Wähle .asf Datei aus','Fz','MultiSelect','on');
% Open filebrowser and select different tests manually

v_tekscan = 0.0409;
% Velocity Tekscansheet with respect to the tire

R= [];
% Initiate R for structure R. Used for data about reliability and reproducibility

for i=1:numel(FileName)

    filename=strcat(PathName,FileName);function [TSmtrx,TKS,TEKSCAN_INFO] = read_txt_tekscan(filename)
% filename
% Script to convert TekScan ASCII data to matlab data.
% The configuration of the TekScan software should be:
%
% Number of Frames: 250 [-]
% Seconds per Frame: 0.04 [s]
%
% HOW TO USE
%
% Enter: read_txt_tekscan(filename)
% to start the conversion.
%
% INPUT
%
% An ASCII file containing data from a TekScan movie
%
% OUTPUT
%
% M_movie, containing the footprint in a 3D matrix [mxnxp]
% m = length of the footprint
% n = width of the footprint
% p = frame number (time step)
% 1 output unit = 0.1 [Bar]

fid = fopen(filename);
errmsg = '';
while fid < 0
   disp(errmsg);
   filename = input('Open file: ', 's');
   [fid,errmsg] = fopen(filename);
end
% Open filename for read access
tline ='a';
% Tline may not be empty at the beginning, so the value 'a' is arbitrary
p = 1;
% Start at Frame 1
movie = zeros([176,192,250]);
% Preallocating memory for variable
%41
str = sprintf('open %s', char(filename));
TEKSCAN_INFO = [];
% Cell array of strings for information about test
disp(str)
% ***********************************************************************
% ***********************************************************************
while isempty(tline) || ( ~isempty(tline) && ~strcmp(tline(1),'@') )
% When a '@' is read, the end of the file is reached
    if isempty(tline)
        tline = fgetl(fid);
% Line with text: Frame (number), go to next line
        %tline = fgetl(fid);
% Read first line of data
        m = 1;
        while ~isempty(strfind(tline,',')) % . vervangen door ,
% As long as there is data in tline
            tline = strrep(tline,',',' ');
% Change the seperation comma into an empty space.
            movie(m,:,p) = sscanf(tline,'%f',[1,192]);
% Write data into variable 'movie' (%f = floating point numbers)
            m = m + 1;
% Next m (is next line of sensels)
            tline = fgetl(fid);
% Read next line of data
        end
        % End while
        p = p + 1;
        % Next p (is next frame (timestep))
    else
        [tline,lt] = fgets(fid);
    % Read empty line
        TEKSCAN_INFO = char(TEKSCAN_INFO,tline);
    % Store test infomartion in info matrix
        parameters_temp = sscanf(tline,'%s %*f');
    % Temporary parameter storage
        switch parameters_temp
            case 'ROWS'
                TKS.ROWS = sscanf(tline,'%*s %f');
            % Tekscan rows
            case 'COLS'
                TKS.COLS = sscanf(tline,'%*s %f');
            % Tekscan columns
            case 'ROW_SPACING'
                TKS.ROW_SPACING = sscanf(tline,'%*s %f')/1000;
            % Space between rows [m]
            case 'COL_SPACING'
                TKS.COL_SPACING = sscanf(tline,'%*s %f')/1000;
            % Space between columns [m] 42
            case 'SENSEL_AREA'
                TKS.SENSEL_AREA = sscanf(tline,'%*s %f')/1000^2;
            % Sense area [m^2]
                if sscanf(tline,'%*s %*f %s')=='inš'
                    % Test for inches or mm and change units
                    TKS.SENSEL_AREA = TKS.SENSEL_AREA*25.4^2;
                    TKS.ROW_SPACING = TKS.ROW_SPACING*25.4;
                    TKS.COL_SPACING = TKS.COL_SPACING*25.4;
                end
            % end for
            case 'NOISE_THRESHOLD'
                TKS.TRESHOLD = sscanf(tline,'%*s %f');
            % Noise treshold used by Tekscan
            case 'SECONDS_PER_FRAME'
                TKS.SAMPLETIME = sscanf(tline,'%*s %f');
            % Seconds per frame
            case 'Bandmaat:'
                TKS.TIREWIDTH = sscanf(tline,'%*s %f');
            % Tirewidth as in normal tiredimensions
                TKS.TIREHEIGHT = sscanf(tline,'%*s %*f %*c %f');
            % Tireheight as in normal tiredimensions. In precentage (as usual)
                TKS.TIRERADIUS = sscanf(tline,'%*s %*f %*c %*f %*s %f');
            % Tireradius as in normal tiredimensions
            case 'Belastung:'
                TKS.LOAD = sscanf(tline,'%*s %f');
            % Load [kg]
            case 'START_FRAME'
                TKS.FFRAME = sscanf(tline,'%*s %f');
            % First frame (in principal always 1)
            case 'END_FRAME'
                TKS.FRAMES = sscanf(tline,'%*s %f');
            % Last frame (also refered to as number of frames)
            otherwise
    % Just continue when no case is true
        end
    % End switch
    end
    % End if
end
% End while
fclose(fid);
% Close file
TSmtrx = permute(movie,[2,1,3]);
% Reshape matrix
disp('TSmtrx')
% TSmtrx = uint8( floor(TSmtrx * 10));
% Convert to uint8 for memory reasons, Output: 1 [unit] = 0.1 [Bar]
end
% End function
Private Nachricht senden Benutzer-Profile anzeigen


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.499
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 06.11.2014, 23:20     Titel:
  Antworten mit Zitat      
Hallo,

dann lass doch mal den Debugger laufen und schaue, was parameters_temp in der Zeile ist.
Meine Vermutung ist, dass der Code für eine Datei mit leicht abweichendem Format geschrieben wurde. Letztlich wirst du bzw. der Programmierer herausfinden müssen, wo die Unterschiede liegen und wie man damit umgehen kann.

Grüße,
Harald
Private Nachricht senden Benutzer-Profile anzeigen
 
Toniblabla
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 3
Anmeldedatum: 06.11.14
Wohnort: ---
Version: Matlab 2014b
     Beitrag Verfasst am: 07.11.2014, 00:23     Titel:
  Antworten mit Zitat      
Danke für die Antwort!
bei parameters_temp kommt wie gesagt der fehlercode oben, wenn ich
num2str(parameters_temp) mache

ans =

68
65
84
65
95
84
89
80
69

Ich denke die struct datei TKS soll gefüllt mit Zahlen werden ,
wie ROW, COL (ect.)
parameters_temp muss den case treffen
Code:

switch (parameters_temp)
            case 'ROWS'
                TKS.ROWS = sscanf(tline,'%*s %f');
            % Tekscan rows
            case 'COLS'
                TKS.COLS = sscanf(tline,'%*s %f');
            % Tekscan columns
            case 'ROW_SPACING'
                TKS.ROW_SPACING = sscanf(tline,'%*s %f')/1000;
            % Space between rows [m]
            case 'COL_SPACING'
                TKS.COL_SPACING = sscanf(tline,'%*s %f')/1000;
            % Space between columns [m] 42
            case 'SENSEL_AREA'
                TKS.SENSEL_AREA = sscanf(tline,'%*s %f')/1000^2;
            % Sense area [m^2]
 

Die asf. datei sieht aus:
DATA_TYPE MOVIE
VERSION Druckmesssystem von Tekscan 6.32
HARDWARE 116-1488-2
MAP_VERSION 6.2
HW_TYPE 4
DATEINAME C:\Tekscan\Research\Database\MOVIES\kk\EggeM03L.fsx
SENSOR_TYPE FSCAN
ROWS 60
COLS 21
ROW_SPACING 0.508 cm
COL_SPACING 0.508 cm
SENSEL_AREA 0.258064 cm2
NOISE_THRESHOLD 3
SECONDS_PER_FRAME 0.08
MICRO_SECOND 0
TIME Freitag, 26. September 2014 11:14:48
SATURATION_PRESSURE 9.34637 kg/cm2
CALIBRATION_POINT_1 65 (Kgs) 6872 (Raw Sum) 317 (Number of Loaded Cells)
CALIBRATION_MODE_1 Punkt
CALIBRATION_INFO C:\Tekscan\Research\Database\MOVIES\kk\EggeM03L.cal
SENSITIVITY Standard
Nachname:
Vorname:
Geburtsdatum: 26.02.1993
Geschlecht: männlich
START_PHASE 1
END_PHASE 1
UNITS kg/cm2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.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,B,B,B
B,B,B,B,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,B,B,B,B
B,B,B,B,B,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,B,B,B,B
B,B,B,B,B,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,B,B,B,B,B
B,B,B,B,B,B,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,B,B,B,B,B,B
B,B,B,B,B,B,B,0.0,0.0,0.0,0.0,0.0,0.0,0.0,B,B,B,B,B,B,B
@@
Private Nachricht senden Benutzer-Profile anzeigen
 
Toniblabla
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 3
Anmeldedatum: 06.11.14
Wohnort: ---
Version: Matlab 2014b
     Beitrag Verfasst am: 07.11.2014, 21:11     Titel:
  Antworten mit Zitat      
Ich habe es selbst rausgefunden:

Code:

parameters_temp =textscan(tline, '%s%*f%*s', 'whitespace', '', 'delimiter', ' ');% sscanf(tline,'%c %*s',inf);
    % Temporary parameter storage
    parameters_temp=strjoin(parameters_temp{1});
 
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.