Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Matlab matrix and plotting help

Subject: Matlab matrix and plotting help

From: Kris Ball

Date: 14 Jan, 2008 12:54:02

Message: 1 of 3

I have a few problems with some matlab work I have.

I need to count the number of positive values in a matrix
0.5-rand(5,6) and find out which element
in the matrix has the largest value.

3. Write a program that use Matlab ‘function’ to do the
following calculations:
(a) the sum of all elements in a matrix;
(b) the mean of all negative elements in the first column of
a matrix.

4. Write a program that will read in a text string mixed
with numbers and letters from the
keyboard and count how many numbers there are in the string.

5. Plot a 3D graphics described by the following equation:
i = 10sin(0.05 f t)
where i is the current in ampere, the time t changes from 0
to 20 seconds and the
frequency f can change from 10 to 15 Hz.

but I can't work out how.

For 3 (a) I can calculate the sum of each coloumn but not
the sum of all elements.

I can get a 2D graphic for question 5 but can't get my head
around how to get a 3D graphic.

Subject: Re: Matlab matrix and plotting help

From: Lars

Date: 14 Jan, 2008 16:39:02

Message: 2 of 3

type the following commands to the command-window:

>> help help

>> help find

>> help max

>> help min

>> help size

>> help mesh

>> help sum

>> help mean

>> help input

>> help >

and find out about the colon-operator (:)

Note that you should not use i or j as a variable since they
are reserved. >> help i

LARS

Subject: Re: Matlab matrix and plotting help

From: Volkan

Date: 14 Jan, 2008 16:48:03

Message: 3 of 3

Hi,

You seem to have extended your questions to tags section. So
I'll start from there:

To get help on a particular function, say sum, type 'help
sum' at the command prompt. Also hitting F1 brings out a
nice documentation.

> For 3 (a) I can calculate the sum of each coloumn but not
> the sum of all elements.

Why not repeat the sum operation to get the sum of column
sums. Or convert your matrix to a single vector before
applying sum.
help sum
help colon

> I can get a 2D graphic for question 5 but can't get my head
> around how to get a 3D graphic.

I'm guessing you are using plot. Try surf or mesh.

> 4. Write a program that will read in a text string mixed
> with numbers and letters from the
> keyboard and count how many numbers there are in the string.

Hint: str2double('4') returns 4, whereas str2double('c')
returns NaN.

> (b) the mean of all negative elements in the first column of
> a matrix.

There are so many different approaches to this one, that I
wouldn't want to limit your creativity.

Volkan

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
getting to know matlab Volkan 20 Jan, 2008 03:35:39
does matlab have help Shaun 14 Jan, 2008 10:26:49
homework Shaun 14 Jan, 2008 10:26:29
getting to know matlab Shaun 14 Jan, 2008 10:26:16
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics