How to assign value in multidimensional variable?

I was trying to assign value in a multidimensional variable. My first code is wroking Here it is:
prod = 1; ch = 1;
AAA(prod,ch,:) = A;
This code gives me this output in worksapce
But My 2nd code where I just increase the number of dimension. It gives me error. Here is the code:
prod = 1; ch = 1;sub = 1;
AAA(sub,prod,ch,:) = A;
This gives me error like this:

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 23일
편집: Ameer Hamza 2020년 11월 23일

0 개 추천

It will only give error if AAA is already defined. Try the following code
clear AAA
prod = 1; ch = 1;sub = 1;
AAA(sub,prod,ch,:) = A;

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 11월 23일

편집:

2020년 11월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by