Question
I have a vector A of 30 elements. Each of those elements could be one of three values (1, 2 or 3). There are therefore there are 30^3=27000 possible vectors A. How could I create a matrix [30 x 27000] where each colum in that matrix is a unique A?
Expert Answer
John Williams
PhD Expert
Answered Aug 25, 2026
If you don't have the Deep Learning toolbox,
[c{1:30}]=ndgrid(1:3);
allAs=cat(31,c{:});
allAs=reshape(allAs, [],30).';
Otherwise, you can use combvec,
c(1:30)={1:3};
allAs=combvec(c{:});
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →