MATLAB Answers

0

Attempting to open a script to analyze a PTU file

Asked by Jose Godinez on 20 Jun 2019
Latest activity Commented on by Jose Godinez on 26 Jun 2019
Hello everyone, I am currently trying to analyze a PTU file called "c3_c5_DNA_1.ptu" using a script provided to me called "Read_PTU_V1". I have no experience programming in MatLab and limited experience in other languages. I have tried modifying the parts of the script I believe I need to edit to make it work, but I've been unsuccessful up to the moment. The following lines correspond to the parts of the script I believe need to be modified. The only changes I made are adding the path of the files to where I believed the script needed them. I have attached copies of those two sections for reference.
Original Script:
function [output, txtout]=(filepath) % Read PicoQuant Unified TTTR Files
My Change:
function [output, txtout]=('C:\Users\jgodinez6\Desktop\Read_PTU_V1') % Read PicoQuant Unified TTTR Files
Another section (original):
fid=fopen(filepath);
My change:
fid=fopen('C:\Users\jgodinez6\Desktop\c3_c5_DNA_1.ptu');
This is the error I get when I try to run it:
>> Read_PTU_V1
Error: File: Read_PTU_V1.m Line: 1 Column: 39
Unexpected MATLAB expression.
I will really appreciate your support. Thank you!

  0 Comments

Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 20 Jun 2019
 Accepted Answer

Jose - the problem is with the signature of this function
function [output, txtout]=(filepath)
While you are providing the input and output parameter names, you are not supplyinbg a function name. See Declare function name, inputs, and outputs for details on how to do this. In your case, you would do something like
function [output, txtout] = myFunction(filepath)
and save this to a file myFunction.m. This is an example only...you can name it to be whatever you want but the function name must match the file name.
You would then call this function from the command line (or another script or function) as
>> [output, txtout] = myFunction('C:\Users\jgodinez6\Desktop\Read_PTU_V1')
where you pass in the path and name of the function that you want to process. Since you are passing in this string, then this is the value of the filepath input parameter, and so the line to open the file can still remain as
fid=fopen(filepath);

  3 Comments

I think your suggestion solved part of the issue. However, it still indicates there is an error on the path. This is what is showing me:
Error: File: Read_PTU_V1.m Line: 1 Column: 39
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other
syntax error. To construct matrices, use brackets instead of parentheses.
Thi is line 1:
function [output, txtout]=Read_PTU_V1('C:\Users\josec\OneDrive\Documents\MATLAB')
Jose - your function signature (line 1) is incorrect
function [output, txtout]=Read_PTU_V1('C:\Users\josec\OneDrive\Documents\MATLAB')
In the above you, need to define the input parameter as a variable and not as a string. You pass the string when you call the function. So your line 1 must become
function [output, txtout]=Read_PTU_V1(filepath)
where filepath is the input parameter for this function which will then be evaluated in the code. You set this input parameter with a value when you call the function from the command line (or from another script or function) as
>> [output, txtout]=Read_PTU_V1('C:\Users\josec\OneDrive\Documents\MATLAB')
Please see the attached simple example.
I think this worked. Thank you!

Sign in to comment.