フィルターのクリア

how to create a matrix from existing matrix

1 回表示 (過去 30 日間)
shanmukh
shanmukh 2013 年 2 月 19 日
I have matrix A and need to create matrix B. Please let me know how to do it Sample: if true
A B
0.25 0
0.25
0.50
0.75
1
0.20 1.20
1.40
1.60
1.80
2
0.15 2.15
2.30
2.45
2.60
2.85
3
0.20 3.20
3.40
3.60
3.80
4
0.10 4.10
4.20
4.30
4.40
4.50
4.60
4.70
4.80
4.90
5
- -
- -
- -
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 19 日
What is the relation between A and B?
Why for .2 there is 5 values and for 0.15 there is 6?

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

採用された回答

José-Luis
José-Luis 2013 年 2 月 19 日
a = [0.25 0.20 0.15 0.20 0.1];
your_mat = cell2mat(arrayfun(@(x,y) ((x:x:1)'+y)',a,0:numel(a)-1,'uniformoutput',false));
your_mat = [0;your_mat'];
  1 件のコメント
shanmukh
shanmukh 2013 年 2 月 19 日
i am getting an error
if true
Error using arrayfun
All of the input arguments must be of the same size and shape.
Previous inputs had size 14163 in dimension 1. Input #3 has size 1.
Error in text_fin1 (line 52)
time = cell2mat(arrayfun(@(x,y)
((x:x:1)'+y)',n,0:numel(n)-1,'uniformoutput',false));

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 19 日
A=[0.25 0.2 .15 .2 .1]
a=cell2mat(arrayfun(@(x) x+A(x)-1:A(x):x,1:numel(A),'un', 0 ))'
  1 件のコメント
shanmukh
shanmukh 2013 年 2 月 20 日
thank you

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

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by