0
votes

Hey I have a problem where I have two potential ways the input data for a function can be entered.

One way is through a cvs file containing the data, the other is directly through a matrix.

Here is my code to get around this..

function printRouteStats(routeData)
    % displays route info basedf on data  for mountain bike tracks
    if isa(routeData,'string')
        gpsPoints = csvread(routeData); %fix this later as currently giving a string
    else
        gpsPoints = routeData;
    end
end

This works for say printRouteStats([0 0 0; 0 300 10; 100 300 20; 100 500 -10; 400 500 -10])

but for printRouteStats('exampledata.csv') is gives output of exampledata.csv as a string, rather than produce the desired matrix.

Any suggestions?

Thanks

Sorry I've only been learning matlab for two weeks so it's probably a really simple question for everyone here.

1

1 Answers

0
votes

class(routeData) is char not string. To check use isa(routeData,'char') or ischar(routeData)