Skip to main content
1-Visitor
June 9, 2015
Solved

How do I convert matrix or column from string to number?

  • June 9, 2015
  • 2 replies
  • 3397 views

OK, I successfully imported .csv file into Mathcad Prime using READCSV.

My .csv file contains a table, one column are dates and another are numbers, there also a spurious empty columns.

I have no idea how to deal with dates, but my primary interest is second column with numbers.

But problem is, Prime interprets the whole csv table as matrix of string values, despite of numbers on second column are well-formed.

I tried str2num function, but it refuses to do the job, probably due non-scalar input. How do I pre-process this column to finally start my real calculations?

As a bound, could anyone please advise on dates in the following format: "2010-06-26",...

Thank you.

Best answer by RichardJ
I tried str2num function, but it refuses to do the job, probably due non-scalar input.

Use the vectorize operator

 

As a bound, could anyone please advise on dates in the following format: "2010-06-26",...

You will have to use Mathcad's string functions to convert that to three numbers, but then to use that date see here: Date Calendar and Time functions.mcd - PTC Community

2 replies

RichardJ19-TanzaniteAnswer
19-Tanzanite
June 9, 2015
I tried str2num function, but it refuses to do the job, probably due non-scalar input.

Use the vectorize operator

 

As a bound, could anyone please advise on dates in the following format: "2010-06-26",...

You will have to use Mathcad's string functions to convert that to three numbers, but then to use that date see here: Date Calendar and Time functions.mcd - PTC Community

yrereq1-VisitorAuthor
1-Visitor
June 11, 2015

As a bound

This one is an autocorrection artifact, ofc I mean to say "As a bonus".

Thanks,