Question

In: Computer Science

P4.2.7 Write a script that draws a bullseye with n concentric rings. The kth ring should...

P4.2.7 Write a script that draws a bullseye with n concentric rings. The kth ring should have inner radius k – 1 and outer radius k. (Thus, the innermost ring is just a radius-1 disk.) The kth ring should be colored white if k is odd and red if k is even.

This is a matlab problem

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc
clear all
close all
format long
n=5;
hold on;
for k=1:n
plotCircle(k);
end
set(gca,'Color','k');
axis equal;
function plotCircle(r)
th=0:0.01:2*pi+0.1;
x=r*cos(th);
y=r*sin(th);
if(mod(r,2)==0)
plot(x,y,'r')
else
plot(x,y,'w');
end
end

Kindly revert for any queries

Thanks.


Related Solutions

Write a program in a script file that creates m × n matrix with elements that...
Write a program in a script file that creates m × n matrix with elements that have the following values. The value of each element in the last row is the number of the column. The value of each element in the last column is the number of row +1. For the rest of the elements, each has a value equal to the sum of the element below it and the element to the right.
it should be c++ data structure Write a recursive function that draws the following shape. X...
it should be c++ data structure Write a recursive function that draws the following shape. X XXX XXXXX XXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXX XXXXX XXX X The length of the longest row in the shape and the shape's character are function parameters. In above shape the longest row is 9 and the pattern's character is "X”.
USING RSTUDIO: Write a script that allows two people to play tic-tac-toe. The script should allow...
USING RSTUDIO: Write a script that allows two people to play tic-tac-toe. The script should allow each player to take sequential turns and to interactively enter their choice of position at the command line on each turn. For each turn, the script should output the set-up of the board. Note, you don’t have to use “x” and “o” as the symbol of each player. Note, the main body of this code (not including functions) should be able to be written...
write a script file that calculated the first n perfect numbers. use the WHILE structure the...
write a script file that calculated the first n perfect numbers. use the WHILE structure the perfect number is a positive integer that is equal to the sum of its multiples for example 6 is a perfect number since it’s multiplied are 1, 2 and 3. 1+2+3=6 the result must be stored in a vector where all calculated perfect numbers appear. you must use the rem command matlab
Write a script that creates and calls a stored procedure named test. This procedure should identify...
Write a script that creates and calls a stored procedure named test. This procedure should identify all of the prime numbers less than 100. (A prime number is an integer that can't be divided by another integer other than 1 and itself.) Then, it should display a string variable that includes the prime numbers like this: 2 1 3 1 5 1 7 1 1 1 1 1 3 1 1 7 1 1 9 1 2 3 1 2...
Write a bash script file that tests each file entry in the current directory. It should...
Write a bash script file that tests each file entry in the current directory. It should determine if it is a file or directory. If it is a file, it will determine if it is readable or not. If it is readable, it will display only the first 4 lines to the terminal in sorted order (just sort the first 4 lines). If it is a directory, it should display the contents of that directory (the files and subdirectories). NOTE:...
this lab, you will write a shell script, called compare_cols.sh. This program should Read a CSV...
this lab, you will write a shell script, called compare_cols.sh. This program should Read a CSV file from standard input (STDIN). Note that in general, CSV files may contain quoted fields with embedded newlines. But for this assignment you can assume that there are no fields with embedded newlines, and therefore each new line represents a new row of the CSV file. Print a single number (integer) to standard output (STDOUT): the count of the lines in the CSV file...
Write script in Matlab to solve 1. Y=Ax where X is of dimension n by 1...
Write script in Matlab to solve 1. Y=Ax where X is of dimension n by 1 and A is of dimension m by n. 2. C= A*B where A is of dimension m by p and B is dimension of p by n. So write matlab script to obtain Y and C in above problems.
Write and upload a MATLAB script to do the following. Compute the sequence S(n+1) = (2...
Write and upload a MATLAB script to do the following. Compute the sequence S(n+1) = (2 – K) S(n) – S(n-1) ;   Assume S(1) = 0, S(2) = 1; (a)    Case 1, Assume K = 1 (b)    Case 2, Assume K = 2 (c)     Case 3, Assume K = 4 Plot all of these on the same plot, for N = 1 to 20
write matlab script of N channel MOSFET (Iv curve) will like and comment if done correctly...
write matlab script of N channel MOSFET (Iv curve) will like and comment if done correctly plesse
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT