How to assign value in multidimensional variable?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jhon Gray
le 23 Nov 2020
Modifié(e) : Ameer Hamza
le 23 Nov 2020
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:

0 commentaires
Réponse acceptée
Ameer Hamza
le 23 Nov 2020
Modifié(e) : Ameer Hamza
le 23 Nov 2020
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!