How can i convert a matrix to a specific feature with matlab
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everybody.
I need desperately your help as I am not very familiar with Matlab. Let assume that I have two matrixes for instance
a=[205;165;175;165;135]
b=[25;25;55;65;65] (dimension 5x1 each one)
What I want to do is to take the numbers from each row of the matrixes a and b and have a new one with a specific feature like
c=[205 25,165 25,175 55,165 65,135 65]
In more general I want to have a new matrix
C=[a11 b11,a21 b21,a31 b31,…aj1 bj1,…ai1 bi1]
if the a and b matrixes have ix1 dimension . Also bear in mind that C matrix has a specific feature as I have mentioned so far. What I mean with this is between some aj1 and bj1 there is a space gap and each pair let say a21 b21 and a31 b31 is separated by a comma (,).
Thanks everybody for your help
0 件のコメント
回答 (2 件)
Guillaume
2015 年 12 月 18 日
Spaces, commas, semicolons are all syntactic elements that are not part of the data that is stored in a matrix. It's only used as for display and input. As far as matlab is concerned a matrix is just a bunch of numbers.
Therefore, your specific feature is not possible. spaces and commas mean the same thing when you input a matrix and matlab displays them both as space. semicolons mark the end of a row, when you input a matrix and matlab displays that as a new line.
It sounds like you're confusing the display of a matrix with the content. As said, a matrix is just numbers. spaces and commas do not feature into it.
1 件のコメント
Walter Roberson
2015 年 12 月 23 日
Ang Vas replied in a duplicate question:
is any other alternative way to do this feature with numbers and commas? Actually what I am trying to do is to have the numbers in such row as to be able to import them in Inkscape
Walter Roberson
2015 年 12 月 23 日
As you want this for display (output) purposes,
t = sprintf('%g %g,', [a,b].');
c = [ '[', t(1:end-1), ']' ]; %trim trailing comma
Now you can output the string c
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!