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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

采纳的回答

Rik
Rik 2021-5-18
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by