Info

This question is closed. Reopen it to edit or answer.

can you help me with solving the problem?

1 view (last 30 days)
Phanuphong
Phanuphong on 23 Nov 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
r = 0 : 0.01 :2;
t = 0.1 : 0.1 : 1;
K = (r^2)/(sqrt((1-r^2)^2+(2*t*r)^2));
plot(r,K);
K is error. Error using ==> mpower........ Matrix must be square.

Answers (1)

Star Strider
Star Strider on 23 Nov 2014
You have to vectorise your ‘K’ assignment, and ‘r’ and ‘t’ must have the same number of elements.
This works:
r = linspace(0,2);
t = linspace(0,1);
K = (r.^2)./(sqrt((1-r.^2).^2+(2*t.*r).^2));
plot(r,K);
Vectorising does element-wise operations, and uses the dot operator to indicate it, such as replacing (*) with (.*), (^) with (.^), and (/) with (./).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!