フィルターのクリア

X labeling from file

2 ビュー (過去 30 日間)
Micah
Micah 2011 年 9 月 9 日
I have a file formatted as follows:
a c g g t c c a
I want to use those characters as labels for a plot. I understand you can use set(gca,'XTickLabel',{var}) to set the axis, but I can't seem to import the data in a way that it can be read. I have tried textread, textscan, csvread (putting commas after ever character), and straight importdata. I can get a 1xn array consisting of those characters, but I can't use them as labels. Error message is:
??? Error using ==> set
Cell array of strings may only contain string and numeric matrices
Any advice?
Thanks

採用された回答

Micah
Micah 2011 年 9 月 9 日
I got it to work using the following:
bars = [0,0,985,62,...] (the data)
num = [1, 2, 3, 4,...] (just integers increasing)
seq = [a,f,c,f,...] (the labels)
plot(bars)
set(gca,'XTick',[num])
set(gca, 'XTickLabel', seq)

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 9 月 9 日
labs = textscan(fid, '%s');
set(gca, 'XTickLabel', labs);
  2 件のコメント
Micah
Micah 2011 年 9 月 9 日
That doesn't seem to work. I typed
>> fid = fopen('x.txt');
>> labs = textscan(fid, '%s');
>> set(gca,'XTickLabel',{labs})
??? Error using ==> set
Cell array of strings may only contain string and numeric matrices
Micah
Micah 2011 年 9 月 9 日
also tried
>> fid = fopen('x.txt');
>> labs = textscan(fid, '%s');
>> set(gca, 'XTickLabel', labs)
(using no braces)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by