How to concatenate strings in Matlab with special characters?
조회 수: 10 (최근 30일)
이전 댓글 표시
Hello,
just want to do the following things:
prompt = 'Please give the path of the import file: ';
str = input(prompt, 's');
% the user will give a path like C:\..\file.txt %
%str = C:\..\file.txt%
fid = fopen(str); %here error, because fopen needs an argument in ''%
%in stead of fopen(C:\..\file.txt), fopen('C:\..\file.txt')%
I wanted to concatenate the str with other character "'". How shall I do this?
Thanks
Lizhi
댓글 수: 1
Chandrasekhar
2014년 4월 8일
편집: Chandrasekhar
2014년 4월 8일
There is no error found here. May be the path of the file entered is wrong. instead of 'input' you can use 'uigetfile' to locate the file.
답변 (3개)
Joseph Cheng
2014년 4월 8일
I agree with Akshata it doesn't look like there should be an issue. The input should already be a string such that fopen should accept it. May I suggest that instead of using input() for a file path, use [file folder]=uigetfile() which will open the windows open file window.
댓글 수: 0
Andreas Goser
2014년 4월 8일
편집: Andreas Goser
2014년 4월 8일
The string concatenation should not be a problem:
a='ä'
b='ö'
[a b]
However maybe the commands before?
댓글 수: 0
Walter Roberson
2014년 4월 8일
fopen() does not need to be passed a literal: passing a string value is fine.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!