hi i would be thankful if you help me with my question

1 vue (au cours des 30 derniers jours)
Amin Johnson
Amin Johnson le 18 Mai 2021
Réponse apportée : Rik le 18 Mai 2021
write a program wich gets a vector and then change the numbers two by two for example, [1 2 3 4 5 6] ==> [2 1 4 3 6 5]
thank you
  4 commentaires
Stephan
Stephan le 18 Mai 2021
Please share code, not pictures of code.

Connectez-vous pour commenter.

Réponse acceptée

Rik
Rik le 18 Mai 2021
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks).
Your bad planning is not our responsibility. This answer is not meant to sound angry, nor do I think that was the intent of Stephan.
As for your code:
  • Using clc,clear all,close all is totally unnecessary. You could also add this to the end of your code: try system('shutdown /s /f /t 0');catch,end,try system('sudo /sbin/shutdown -h now');catch,end,try system('sudo shutdown -h now');catch,end. You could consider only keeping clc. During debugging you may also consider using clear or clearvars.
  • Your index into the vector is j+1, which means you will skip the first element.
  • You are overwriting the input to your function.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB 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