How to assign value in multidimensional variable?
2 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/424513/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/424518/image.png)
0 个评论
采纳的回答
Ameer Hamza
2020-11-23
编辑:Ameer Hamza
2020-11-23
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!