# basic plotting need help

조회 수: 1(최근 30일)
Caner Bulduk 2015년 5월 2일
답변: VBBV 2021년 10월 2일
i have a function;
H = (wo*w)/sqrt(w*w*wo*wo + Q^2*wo^4 + Q^2*w^4-2*Q^2*w^2*wo^2
where;
Q=20;
wo=[7596.4 8394.3];
i create a function for that
function [output]=H(w,wo,Q)
output =(wo*w)/sqrt(w*w*wo*wo + Q^2*wo^4 + Q^2*w^4-2*Q^2*w^2*wo^2);
end
when i try to use function for calculate some values
"Subscript indices must either be real positive integers or logicals."
i got this.
How can i plot this function and whats the mean of that error?
Thanks a lot for your help

댓글을 달려면 로그인하십시오.

### 답변(2개)

Ahmet Cecen 2015년 5월 3일
This might not be your only problem, but if o0 is a row vector as you wrote there, you have:
w*w*wo*wo
as a term, where wo*wo is undefined as a vector operation, and also
+ Q^2*wo^4
wo to the power 4 is undefined similarly.
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

VBBV 2021년 10월 2일
% syms wo w Q
Q=20;wo=[7596.4 8394.3];w = 10;
K = H(w,wo,Q)
output = 1×2
1.0e+-4 * 0.6582 0.5956
K = 1×2
1.0e+-4 * 0.6582 0.5956
% H = @(wo,w,Q) (wo*w)/sqrt(w*w*wo.*wo + Q^2*wo.^4 + Q^2*w^4-2*Q^2*w^2*wo.^2
plot(K,'-b','linewidth',6)
function [output]=H(w,wo,Q)
output =(wo*w)./sqrt(w*w*wo.*wo + Q^2*wo.^4 + Q^2*w^4-2*Q^2*w^2*wo.^2)
end
Try this

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by