help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resolution exercise Octave


From: Brett Green
Subject: Re: Resolution exercise Octave
Date: Wed, 6 May 2020 21:05:07 -0400


On Wed, May 6, 2020 at 9:01 PM Nicholas Jankowski <address@hidden> wrote:
On Wed, May 6, 2020 at 8:43 PM Simone <address@hidden> wrote:
Can you help me to solve this question:

Create ranges of values from one to ten and store in a variable called R1.
In R2, store non-integer values in the range of one to ten, with steps of
0.2

ok, I just walked my daughter through some of this as she's learning Octave/Matlab :)

Assuming you know the basics of 'storing values in a variable', you should learn how to use the colon ( : ) operator to specify a range.

see the Octave documentation page on Ranges:

it has examples for everything you should need to work through the problem. 




You can check whether a value (say, x) is an integer with

if floor(x)==x
% Put your code here for what will happen with integer values
end

You can check all elements of R2 with a for loop:

for j=1:length
% Type your code here for what you want to do with element number j of the array R2
end

and lastly you can remove an element form an array by setting it to be empty:

% This code removes the kth element of R2
R2(k) = [];

With these three you have all the ingredients you need - can you solve it now?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]