resizing an array in MATLAB

8 ビュー (過去 30 日間)
Gernot Beer
Gernot Beer 2020 年 2 月 20 日
回答済み: Athul Prakash 2020 年 2 月 23 日
I have an array that is declared global and after first definig it and using it with size [1,3] - for example - I want to resize it to be [1,2] for the next step.
Code:
> global sin
> sin= [1 2 3]
> resize sin to only have 2 columns.
Thanks for your help.
  2 件のコメント
Alex Mcaulley
Alex Mcaulley 2020 年 2 月 20 日
This is very basic. I recommend you to do the Matlab tutorial
the cyclist
the cyclist 2020 年 2 月 20 日
I second the general recommendation to go through a basic tutorial.
But, also, I have some suggestions/questions:
  • You should not define a variable called sin. That is a MATLAB keyword for the sine function. It is poor programming practice to name variables with keywords.
  • Why are you defining the variable to be global? That is almost never necessary, especially in the sorts of programs a beginner will be using.
  • Your variable has 3 values. How can you make it into a size [1,2] array? Do you want to discard a value?

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

回答 (1 件)

Athul Prakash
Athul Prakash 2020 年 2 月 23 日
I think what you're looking for is a way to index. I'm sure you'll find the answer here:
If you want a solid grip on MATLAB basics, have a look at the MATLAB Onramp:
Hope it Helps!

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by