I have a program that calculates the inverse of a matrix. However, in my for loop I generate n vectors y which are nx1 vectors. The vectors are correctly calculated, but I can't figure out how to concatenate them into an nxn matrix.(adsbygoogle = window.adsbygoogle || []).push({});

The problem I think I'm having is that my vector y is generated but it isn't indexed ie y_1, y_2, or something like that. So I can't just make X=[y_1 y_2 ...]. Each time the loop runs it erases y and replaces it with the new y, so at the end I only have the nth vector left.

Does anyone know of a way to fix this so the output each loop would be [y_1] -> [y_1 y_2] -> ... n times?

This is my first program using MATLAB and I am quite stuck, thanks in advance.

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Vector concatenation in for loop (MATLAB)

Loading...

Similar Threads for Vector concatenation loop | Date |
---|---|

Mathematica Looping through vectorized functions for a piecewise solution | Mar 26, 2018 |

MATLAB vector multiplication | Aug 28, 2017 |

MATLAB A Q on multiplying two vectors | Mar 25, 2017 |

New to Matlab, help with vectors | Feb 20, 2016 |

Vector concatenation without using a for loop (MATLAB) | Jan 22, 2014 |

**Physics Forums - The Fusion of Science and Community**