Effacer les filtres
Effacer les filtres

Loop to create a matrix with adding a constant value to a matrix

4 vues (au cours des 30 derniers jours)
Min
Min le 28 Août 2023
Modifié(e) : Dyuman Joshi le 28 Août 2023
I am trying to make a loop that can save the iterations and add a contant value to a matrix.
For example,
I am very sorry for the poor picture :( hopefully there is an easy way to do this. Thanks
  1 commentaire
Les Beckham
Les Beckham le 28 Août 2023
You will need to provide more detail to get a good answer. For example:
  1. What have you tried so far (show your code) and why do you think it isn't working? If you are getting error messages, cut and paste the entire error message (everything in red in the command window).
  2. How many of each "constant" should be in the final vector and what are the values of the "constants"? Just 0, 2, and 4?
  3. Why do you think you need a loop in the first place?
Also, if you are just getting started with Matlab, I would highly recommend that you take a couple of hours to go through the free online tutorial: Matlab Onramp

Connectez-vous pour commenter.

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 28 Août 2023
Modifié(e) : Dyuman Joshi le 28 Août 2023
You can either
It is not recommended to dynamically grow arrays (refer to the preallocation link mentioned above for more information)

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by