Hi Guys
So I have a matrix
a = [16 456 22 85 93;
11 78 310 62 36;
1 66 23 67 405]
how would I add/delete row or column in the matrix? - plot a graph, hold on/hold, turn on grid and label x and y axis?
thank you :)

3 件のコメント

Jan
Jan 2016 年 5 月 2 日
What exactly is your question? Adding deleting rows/columns is explained exhaustively in the Getting Started chapters of the documentation. You find descriptions there also about how to plot a graph, the hold command, labels and grids. So do you aks to rephrase the documentation? Simply use the help and doc commands.
Stephen23
Stephen23 2016 年 5 月 2 日
編集済み: Stephen23 2016 年 5 月 2 日
You got links for all of those topics in answer to your earlier question:
Has something changed since you received (and accepted) that answer?
Adding and accessing elements to arrays is a very basic MATLAB usage that you would be better off learning by doing these introductory tutorials:
We are volunteers, not a private tutorial service: the internet has thousand of MATLAB tutorials that will teach you how to to start using MATLAB.
Laura McHugh
Laura McHugh 2016 年 5 月 2 日
Hi Stephen
Thank you for your reply, I wanted to ensure that the answers are correct and I am going in the right direction

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

 採用された回答

Star Strider
Star Strider 2016 年 5 月 2 日

1 投票

Here you go:
a = [16 456 22 85 93;11 78 310 62 36;1 66 23 67 405];
% Add Row:
a = [a; randi(99, 1, 5)];
% Add Column:
a = [a, randi(99, 4, 1)];
% Delete Row #2:
a(2,:) = [];
% Delete Column #2:
a(:,2) = [];
% Redefine ‘a’:
a = [16 456 22 85 93;11 78 310 62 36;1 66 23 67 405];
x = 1:size(a,2); % Create ‘x’ Variable
figure(1)
plot(x, a(1,:), '-b')
hold on
plot(x, a(2,:), '.-r')
hold off
grid
xlabel('Time (nanoseconds)')
ylabel('Velocity (Furlongs/Fortnight)')

3 件のコメント

Laura McHugh
Laura McHugh 2016 年 5 月 2 日
Thank you for taking time to answer this, wanted to ensure that I am using matlab correctly and these answers are great
Star Strider
Star Strider 2016 年 5 月 2 日
My pleasure.
When I was in initially learning MATLAB, there were a half dozen of us in the Control Engineering computer lab learning control systems and MATLAB simultaneously. We discovered different things at different times, and helped each other learn both. When it came time to do our own work and not collaborate, we all did well. This was about 17 years before MATLAB Answers began. MATLAB was much smaller then as well, and it was much easier to find information in the documentation (which were all only hardcopy back then, and for the Student Edition, in a single book).
Laura McHugh
Laura McHugh 2016 年 5 月 2 日
The documentation and materials I have are good, sometimes it just taking another persons view to ensure you're on the right track with answers, can I ask when adding rows/ columns what randi means?

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

その他の回答 (1 件)

the cyclist
the cyclist 2016 年 5 月 2 日

1 投票

Your question is effectively "How do I use MATLAB?"
Rather than explain that here, which might take up a bit of space, let me point you to this tutorial page.

1 件のコメント

Laura McHugh
Laura McHugh 2016 年 5 月 2 日
great tutorial page, thank you :)

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

カテゴリ

ヘルプ センター および File ExchangeNetworks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by