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

1 回表示 (過去 30 日間)
Amin Johnson
Amin Johnson 2021 年 5 月 18 日
回答済み: Rik 2021 年 5 月 18 日
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 件のコメント
Stephan
Stephan 2021 年 5 月 18 日
Please share code, not pictures of code.
Markus
Markus 2021 年 5 月 18 日
編集済み: Markus 2021 年 5 月 18 日

サインインしてコメントする。

採用された回答

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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by