Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
Beginer matlab question

Subject: Beginer matlab question

From: Kyle Hall

Date: 25 Oct, 2008 18:11:02

Message: 1 of 2

I am trying to use a logical array mask to square all the values of
this array... a = [1:1:2000}. The logical array mask is defined as... b = a <500. How would i square those values using the mask?

Subject: Beginer matlab question

From: Thomas Clark

Date: 25 Oct, 2008 19:18:01

Message: 2 of 2


Firstly, careful - there is a difference between braces and square brackets - thus there is a syntax error in [1:1:2000}. From the context, I'll assume you meant [1:1:2000]...

a = 1:1:2000;
b = a<500;
c = a(b).^2;

Thirdly, MATLAB, unlike most software, has incredibly comprehensive help pages. They're accessible either through MATLAB or online here. If you're asking questions like this, you just have to sit down and read the tutorials and the 'Getting Started' sections. If you post every minor question here, you won't get a very favourable response!

Tags for this Thread

No tags are associated with this thread.

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.

Contact us