cell2mat with 1* 1 cell array
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
Try this
cell2mat([A{:}])
bugatti79
2013년 10월 22일
Hi Azzi,
No luck. The who function returns A as a 1*1 cell
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
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
[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
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
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...
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
