cell2mat with 1* 1 cell array
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Folks,
I have A{ii} which is a cell array 1*1 containing 18*9 matrix. I atttempt to convert to a matrix using B=cell2mat(A) but I get error stating
Cell contents reference from a non-cell array object.
I cannot change A{ii} to A(ii) is it violates
A(I) = B, the number of elements in B and
I must be the same.
Any ideas? Regards B
2 件のコメント
Matt Kindig
2013 年 10 月 22 日
編集済み: Matt Kindig
2013 年 10 月 22 日
What about
B = cell2mat(A{ii})
bugatti79
2013 年 10 月 22 日
Hi Matt,
This is what i had, doesnt work....
採用された回答
Azzi Abdelmalek
2013 年 10 月 22 日
Type
A
whos A
what did you get?
13 件のコメント
Azzi Abdelmalek
2013 年 10 月 22 日
Try this
cell2mat([A{:}])
bugatti79
2013 年 10 月 22 日
Hi Azzi,
No luck. The who function returns A as a 1*1 cell
Azzi Abdelmalek
2013 年 10 月 22 日
What about
b=A{1}
whos b
Hi Azzi,
That seems to have worked in the for loop. Ie, I was able to create an 18*9 double matrix from a 1*1 cell containing 18*9 double using b=A{1} you advised. Can you explain what it is actually doing? Thanks in advanced B
Azzi Abdelmalek
2013 年 10 月 23 日
Post your for loop
bugatti79
2013 年 10 月 23 日
Actually, it doesnt work upon closer examination. b=A{1} means that it keeps the first matrix generated from the first loop and this carries through. I need to keep b as an index because in each loop b will be a different 18*9 matrix.
for ii=1:size(nu_1,3);
i=nu_1(:,:,ii);
A{ii}= i.*n.....
b=A{1}
c{ii}=b.*i %
end
whos
nu_1 18x9x6 double
A{ii} 1x1 cell
n 18*9 double
b 18x9 double
i 18*9 double
Azzi Abdelmalek
2013 年 10 月 23 日
I can't understand what this code is doing. To make your question clear, post a short sample of your data, then ask what you want
Azzi Abdelmalek
2013 年 10 月 23 日
[bugatti79 commented]
Here is the code
nu = [25 25; 25 25]';
nu_1=nu;
nu_1(:,:,2)=50;
nu_1(:,:,3)=150;
nu_1(:,:,4)=300;
nu_1(:,:,5)=400;
nu_1(:,:,6)=450;
n=[ 100 100; 200 200]
for ii=1:size(nu_1,3)
i = nu_1(:,:,ii);
A(ii) = n.*i;
B(ii) =c.*i.*n; % c a constant
C(ii)= i.*n.*B(ii).*C(ii)
end
If I run this code i get error..." A(I) = B, the number of elements in B and I must be the same. "
This is the problem that comes up as outlined in my first post on this thread... Hope this is clearer, thanks B
Azzi Abdelmalek
2013 年 10 月 23 日
There are many errors in your code. you can't use A(ii)=matrix , you should use a cell array A{ii} with curly brackets. Another problem is this
C(ii)= i.*n.*B(ii).*C(ii) % What is the value of C(ii) for ii=1?
Try to adapt this
clear
c=1;
nu = [25 25; 25 25]';
nu_1=nu;
nu_1(:,:,2)=50;
nu_1(:,:,3)=150;
nu_1(:,:,4)=300;
nu_1(:,:,5)=400;
nu_1(:,:,6)=450;
n=[ 100 100; 200 200]
C{1}=ones(size(nu));
for ii=1:size(nu_1,3)
i = nu_1(:,:,ii);
A{ii} = n.*i;
B{ii} =c.*i.*n; % c a constant
C{ii+1}= i.*n.*B{ii}.*C{ii}
end
bugatti79
2013 年 10 月 24 日
My apologies,
C{ii}= i.*n.*B{ii}.*C{ii}
should read
D{ii}= i.*n.*B{ii}.*C{ii}
That should be workable now wit h your code right? Ie, just drop the +1?
Azzi Abdelmalek
2013 年 10 月 24 日
Ok, but what is the value of C?
bugatti79
2013 年 10 月 24 日
C needs to be a matrix not a single numeric value...
Azzi Abdelmalek
2013 年 10 月 24 日
Then just use
D{ii}= i.*n.*B{ii}.*C
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Numerical Integration and Differentiation についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
