[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to strip carriage return or linefeed from a string
From: |
Sergei Steshenko |
Subject: |
Re: how to strip carriage return or linefeed from a string |
Date: |
Tue, 4 Dec 2012 01:59:17 -0800 (PST) |
----- Original Message -----
> From: Hugo Coolens <address@hidden>
> To: address@hidden
> Cc:
> Sent: Tuesday, December 4, 2012 11:52 AM
> Subject: how to strip carriage return or linefeed from a string
>
> I'm looking for a way to put two strings one representing a current
> and one representing a voltage next to each other in a file. The
> following is a code fragment:
>
> usbtmc_write(fd,"MEAS:CURR?");
> resultcurr = char(usbtmc_read(fd,readbytes))
> strrep(resultcurr,'\n','')
> usbtmc_write(fd,"MEAS:VOLT?");
> resultvolt = char(usbtmc_read(fd,readbytes))
> fprintf(file_id, '%s' , [resultcurr resultvolt])
>
> I now get the following output in my outputfile
> 0.0249128
> 0.252767
>
> But I want:
> 0.0249128 0.252767
>
> Can anyone here solve this?
>
> thanks
> Hugo
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
Well, there is a number of ways.
You can delete the last character in a string. e.g. this way:
foo = bar(1:end-1);
.
You can use regular expression.
Regards,
Sergei.