Assignment has more non-singleton rhs dimensions than non-singleton subscripts

I have the codes as follows:
function [H1,c,s,path,d,m]=topology1(topo)
if (strcmp(topo,'access'))
H=zeros(24,18,3);
H1=zeros(size(H,1),size(H,2),3);
H1(:,:,1)=H;
When I want to run the function "topology" I encounter to this error:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Please help me about this issue.

 채택된 답변

You are trying to store all of a 3 dimensional object, H, into a 2 dimensional space, H1(:,:,1)
Perhaps you wanted
H1(:,:1) = H(:,:,1);

댓글 수: 2

Thanks a lot. It did work!
While "it did work". The code is exactly equivalent to:
H = zeros(24, 18, 3);
H1 = H;
which would be much clearer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

질문:

2016년 7월 18일

댓글:

2016년 7월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by