Question
I want to make a 2 column matrix for my x and y data which consists of 1000 datapoints, I have tried this and it replaces only one column: x=[0 1 2 3 4 5]; y=[0 1 2 3 4 5]; A = zeros(1000,2); A(:,2)=y; A(:,1)=x;
Expert Answer
John Williams
PhD Expert
Answered Aug 20, 2026
Your data as you posted them are row vectors. Create column vectors from them to create ‘A’ by either doing a simple transpose (use the .' operator, not '), or forcing them to be column vectors with the ‘(:)’ notation
Try this:
A = [x(:), y(:)]
That should work.
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 →