Matlab code assistance - task 1 and 6 I think I am right and just need to be pointed in the right direction if I should change anything
%% Task 1
% create the 3 row vectors shown in Ex 8 using 3 different approaches
Ex 8 = using the colon operator and also the linspace function, create the following row vectors
-5 -4 -3 -2 -1
5 7 9
8 6 4
% 1. list the values explicitly (square brackets)
vector1=[-5 -4 -3 -2 -1]
% 2. use the colon operator
vector2=
% 3. use the linspace function
vector3=
.
%% Task 6
% Step 1: Assign to myc the current value for time (use the built-in value, clock)
myc = clock;
% Step 2: Store the first three elements of myc in a variable named today
today = myc(1:3);
% Step 3: Store the last three elements of myc in a variable named now
now = myc(length(myc)-2:end);
% Step 4: Use the fix function on now to get the integer portion of time
int_part=fix(now);
.
%% Task 7
% create a 3d matrix having dimensions 2 x 4 x 3.
% Step 1: use the zeros function to initialize the 2 x 4 x 3 matrix
% Step 2: update mat so that the 3rd column of the 2nd layer equals 5.
% Step 3: update mat so that the element in row 2, col 4, layer 2 equals 8.
% Step 4: update mat so that row 2 on layer 2 equals 80% of its former
% value
.
%% Task 8
% Compute the sum of the first 79 terms of the harmonic series shown in Exercise 30.
% Step 1: Use the ones function to create numer, a row vector of 79 ones.
% Step 2: Create denom, a vector of the integers from 1 to 79.
% Do NOT explicitly list 79 values!
% Step 3: Use the ./ operator to compute the quotient of each element pair
% Step 4: Compute the sum of the quotients
Task 1
vector1=[-5 -4 -3 -2 -1];
vector2 =5:2:9;
vector3 = linspace(8,4,3);
Matlab Result
vector1 =
-5 -4 -3
-2 -1
vector2 =
5
7 9
vector3 =
8 6 4
Task 6
Your code is perfact
Task 7
% Step 1: use the zeros function to initialize the 2 x 4 x 3
matrix
mat = zeros(2,4,3);
% Step 2: update mat so that the 3rd column of the 2nd layer equals
5.
mat(:,3,2)=5;
% Step 3: update mat so that the element in row 2, col 4, layer 2
equals 8.
mat(2,4,2) = 8;
% Step 4: update mat so that row 2 on layer 2 equals 80% of its
former value
mat(2,:,2) = mat(2,:,2)*80/100;
Final mat
mat(:,:,1) =
0
0 0 0
0
0 0 0
mat(:,:,2) =
0
0
5.0000 0
0
0 4.0000 6.4000
mat(:,:,3) =
0
0 0 0
0
0 0 0
Task 8
% Step 1: Use the ones function to create numer, a row vector of
79 ones.
vect = ones(1,79);
% Step 2: Create denom, a vector of the integers from 1 to
79.
denom = 1:79;
% Step 3: Use the ./ operator to compute the quotient of each
element pair
quotients = vect./denom;
% Step 4: Compute the sum of the quotients
s = sum(quotients);
Matlab code assistance - task 1 and 6 I think I am right and just need...
Matlab coding assistance. Having some difficulty please help! thank you so much in advance! %% Task 9 % use logical tests to locate and update subsets of a matrix % Step 1: Create vec, a row vector of 5 random integers on the closed interval [-10,10]. % Step 2: Use a logical mask to count the number of positive values (code provided is already sufficient) mask = vec > 0 count = sum(mask) % Step 3: Use the find function...
I just need some matlab help and assistance Refresher 1. Create a vector called A containing 1, 2, 3,4, and 5 2. Create a vector called B containing 6,7, 8, 9, and 10 . Combine A and B to create an array called C where A is the first row and B is the second row 4. Find the 7th element in C 5. Determine the location of 8' in array C
I need this problem to be solved in Excel VBA code. Need full code in VBA. Please solve 1st Task : '5 or 0'. Please help me urgently with proper answer and coding solutions which I can run in Excel/vba. Thanks Course: Programming languages Second laboratory work File and string processing Create a program that processes text file according to task variant. Requirements: 1. Create text file (use notepad) with some lines of data according to task variant. 2. Ask...
on matlab (1) Matrices are entered row-wise. Row commas. Enter 1 2 3 (2) Element A, of matrix A is accesser (3) Correcting an entry is easy to (4) Any submatrix of Ais obtained by d row wise. Rows are separated by semicolons and columns are separated by spaces ner A l 23:45 6. B and hit the return/enter kry matrix A is accessed as A Enter and hit the returnerter key an entry is easy through indesine Enter 19...
Using matlab... Calculating with vectors. Compute the following values. The value of N will be randomized at each submission and will be created by the auto grader. Do not modify the given value of N. Note: N will be a positive integer 2 1. o Compute the mathematical expression below and store the result in the variable named x. Your code should work for any positive integer N given. 2N 1 1 2 3 4 o Hint: Create a numerator...
PLEASE USE MATLAB Create a single MatLab script that On a single line (Line 1), defines matrix A such that A = 1 2 4. 5 7 8 Suppress the echo of A. On a single line (Line 2), use the size function to echo the size of A. On a single line (Line 3), use the length function to echo the length of the entire first row of A. On a single line (Line 4), use linear index notation...
I DESPERATELY NEED HELP WITH THIS DIFFERENTIAL EQUATIONS MATLAB ASSIGNMENT IM SUPPOSED TO BE LEARNING BUT WE HAVE A SUB AND HE DIDN'T TEACH IT! ITS EULER AND IMPROVED EULER IN MATLAB! HERE IS THE LINK FOR THE IMAGE FILE THAT SHOWS THE FULL INSTRUCTIONS FOR THE CODE. https://imgur.com/a/gjmypLs Also, here is my code so far that I borrowed form an old assignment but the data is all wrong and the application of the code is slightly different so either...
Array processing Create a program that processes two-dimensional array according to task variant Additional requirements 1. 2. 3. 4. Input dimensions of array form keyboard (use dynamic memory allocation) Fill array with random numbers in range R. Processing of array should be implemented as function (using indices). Displaying the content of array should be implemented as function (using pointers) 5 12 8 2 8 3 3 16 1 22 215 34 0 11 88 13 22 6 5 81 76...
I only need the "functions" NOT the header file nor the main implementation file JUST the implementations for the functions Please help, if its difficult to do the complete program I would appreciate if you could do as much functions as you can especially for the derived class. I am a beginer so I am only using classes and pointers while implementing everything using simple c++ commands thank you in advanced Design and implement two C++ classes to provide matrix...
second picture is output of the mathlab code Important Note: For testing of this part of the assignment, the automatic printing of values in the com mand window must not be used. Please make sure you put semicolon ω at the end of each line. For this part your program should perform following tasks 1. Create a Matrix A. Show the contents of matrix A to command window with the title Matrix A:". The Matrix A should be defined as...