Merging two vectors (via horzcat) turns everything into zero

Hey everybody! I've stumbled across a serious problem and I cannot fathom if I'm just being too stupid. I have 19 variables called QM1, QM2, QM3 etc., all having one row but different number of columns, such as 1x40 or 1x50. They're all of double-type and consist of values ranging from -1x10^1 to -1x10^8, so all non-zero numbers. I'm trying to merge all of them into one big vector, plotting their absolute value over the corresponding velocities that I have as well on a double-log scale and creating a line of best fit. However, when either using
QMall=horzcat(QM1,QM2,QM3,...,QM19);
or
QMall=[QM1 QM2 QM3 ...];
and then looking at the values of the newly formed vector (which has at least the correct dimension of 1x718), suddenly 99% of the numbers have turned to (1.0e+09 *) 0.0000. The manual creation of the big vector seems to work if I do it gradually, such as QMall=[QM1,QM2,QM3] and then QMall=[QMall QM4 QM5] and so on up until the last two or three variables which then turn into zeros. Has anyone ever encountered this problem before? What I don't get is that it used to work in the beginning, but suddenly it doesn't. Your help would be much appreciated.

 採用された回答

Orion
Orion 2014 年 11 月 13 日

0 投票

Your values didn't became 0.
it's just the display which is not complete.
if you do
a=1e-9;
b=1000;
c= [a b];
disp(c)
1.0e+03 *
0.0000 1.0000
a is still 1e-9.
Change the display format
format long
disp(c)
1.0e+03 *
0.000000000001000 1.000000000000000
it's just visual, the value in unchanged.

1 件のコメント

Ben
Ben 2014 年 11 月 13 日
編集済み: Ben 2014 年 11 月 13 日
Well, that's embarassing. I did think of that of course, but when I tried to plot the data, it looked as if almost all the y-data was zero, too. Only now I noticed that the y-scale was by far too large to show the details. But thank you.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

タグ

質問済み:

Ben
2014 年 11 月 13 日

編集済み:

Ben
2014 年 11 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by