Question

write a code that plots vectors in a matrix one by one. Everytime a vector is...

write a code that plots vectors in a matrix one by one. Everytime a vector is plotted I want to have an option to store in to a one of three (new) matrices eaither by clicking or pressing the keyboard. [MATLAB]

Homework Answers

Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clear, clc
M=randi([1,10],3,10);
[m,n]=size(M);
M1=[];
M2=[];
M3=[];
for i=1:n
plot3([0,M(1,i)],[0,M(2,i)],[0,M(3,i)]);
hold on;
fprintf('For %d vector, in which matrix do you want to put this vector: ');
ch=input('Press 1 for 1, 2 for 2 or 3 for 3: ');
if(ch==1)
M1=[M1 M(:,i)];
elseif(ch==2)
M2=[M2 M(:,i)];
else
M3=[M3 M(:,i)];
end
end
disp('First matrix is');
disp(M1);
disp('Second matrix is');
disp(M2);
disp('Third matrix is');
disp(M3);

Kindly revert for any queries

Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
(This is for Java) I have to write a code that takes three numbers entered from...
(This is for Java) I have to write a code that takes three numbers entered from the keyboard and adds the three numbers.   But for this, I need to use the sum() method
1. Given a matrix variable "mat", write code using for loops, if statements, etc. that will...
1. Given a matrix variable "mat", write code using for loops, if statements, etc. that will accomplish the same as the following: matsum = sum(mat') Please make sure to store the result in "matsum" and dont use sum. This is what I have so far but it keeps telling me is wrong.... % mat has been initialized for you: mat = randi([-100,100],randi([15,20]),randi([15,20])); % write your statements that accomplish the code above: [r c]=size(mat); for i=1:c matsum=0; for j=1:r matsum=matsum+mat(j,i); end...
MATLAB Write a script "readFile.m" which:   a. reads a given file "file.dat" into a matrix "XYZ",  ...
MATLAB Write a script "readFile.m" which:   a. reads a given file "file.dat" into a matrix "XYZ",   b. extracts the columns of the data from "XYZ" into arrays "c1", "c2", ..., "cN",   c. plots some column versus another column, with a title, and labeled axes.   To test and debug your code, create a "file.dat" with 3 rows and N=2 columns ( so a 3×2 matrix ).   The first column should be sorted. You can just enter some numbers in "file.dat" in...
(a) Consider binary codes determined by a parity-check matrix H. Let r be a vector of...
(a) Consider binary codes determined by a parity-check matrix H. Let r be a vector of received symbols. The syndrome of r happens to be a sum of some columns of H. What columns are these? Hint: They are determined by the errors occurring in transmissions. (b) Let G be a k × n generating matrix of a code C the form G = [I_k | B] , where Ik is the k × k identity matrix, and B is...
Matrix Multiplication with Threads - C/C++ **Read entire question before answering** **Don't copy / paste code...
Matrix Multiplication with Threads - C/C++ **Read entire question before answering** **Don't copy / paste code without testing it. I will downvote your answer and mark as spam.** I have posted this question several times, do not copy / paste the same code that has been posted, IT DOESN'T WORK!! In this assignment you will use the Pthreads library to write a program that multiplies two square arrays and compare the difference between the imperative and parallel implementations of this...
For this assignment you need to write a parallel program in C++ using OpenMP for vector...
For this assignment you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is: #pragma...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
(5pts) Vectorize this code! Write one assignment statement that will accomplish exactly the same thing as...
(5pts) Vectorize this code! Write one assignment statement that will accomplish exactly the same thing as the give code (assume that the variable mat has been initialized). [r, c] = size(mat); for i = 1:r for j = 1:c mat(i,j) = 2*mat(i,j)^2 – 6*mat(i,j)+1; end end Use Matlab
Write a function called char_counter that counts the number of a certain character in a text...
Write a function called char_counter that counts the number of a certain character in a text file. The function takes two input arguments, fname, a char vector of the filename and character, the char it counts in the file. The function returns charnum, the number of characters found. If the file is not found or character is not a valid char, the function return -1. As an example, consider the following run. The file "simple.txt" contains a single line: "This...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT