フィルターのクリア

Output to file not working correctly

1 回表示 (過去 30 日間)
Utkarsh Gupta
Utkarsh Gupta 2016 年 5 月 26 日
編集済み: Utkarsh Gupta 2016 年 5 月 27 日
Hello. So I have an input file which is a matrix in formatted form. Now I want to do some operations to change a couple of rows of the matrix and then output the new matrix to another file.
Here I load original file into a matrix (feat), and integers (nb and dim) :
[feat nb dim] = loadFeatures([dataset_dir,Lname{i},'/img',num2str(j),'.mser']);
These are the operations I perform on the matrix feat to insert new values:
var1 = feat(3);
var2 = feat(4);
var3 = feat(5);
t1 = var3-var1;
t2 = (t1 + sqrt(t1.^2 + 4*(var2.^2))/2*var2);
th = atan(t2);
sc = 1;
Now, what I want to do is along with the first 2 rows of the natrix(feat), I want to store a row (th) and sc( a vector filled with the value sc):
for ii = 1:size(1,nb)
fprintf(fid,'%g\t',feat(1,ii),feat(2,ii),sc,th(ii));
fprintf(fid,'\n');
end
fclose(fid)
However, all this does is store the values for only one column. The rest of the columns are somehow ignored.
I am stuck here, and desperately need to figure this out. Any help here would be appreciated. Thank you for your patience.

回答 (1 件)

Stalin Samuel
Stalin Samuel 2016 年 5 月 26 日
fprintf(fid,'%g\t',feat(1,ii),feat(2,ii),sc,th(ii));
%replaced by
fprintf(fid,'%g\t%g\t%g\t%g\t',feat(1,ii),feat(2,ii),sc,th(ii));
  1 件のコメント
Utkarsh Gupta
Utkarsh Gupta 2016 年 5 月 27 日
編集済み: Utkarsh Gupta 2016 年 5 月 27 日
I tried that and I am still getting a single line (single column) as output. As before. I tried outputting some of the matrices ( feat) and they all output the result they're supposed to. I do not know what else to check for here.

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

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by