Warning: Error updating FunctionLine. The following error was reported evaluating the function in FunctionLine update:Array indices must be positive integers or logical value

14 次查看(过去 30 天)
A=10^(-4);
l= 250*10^(-6);
g=0.1517;
e=0.132205;
d=0.142;
K= 2.34*10^(-12);
Yr = @ (w) w*A*e*{d(1-K)+gK}/[l{(1-K)^2 +(gK)^2} ];
fplot(Yr,[10,100],"r")
xlabel('Frequency')
ylabel('Conductance')
grid on

回答(1 个)

Pratyush Swain
Pratyush Swain 2024-5-21
Hi Utkarsh,
The error you're encountering in your MATLAB code is due to the misuse of curly braces {} instead of parentheses () for grouping expressions. Curly braces are used in MATLAB for cell arrays, which is why you're seeing an error about array indices needing to be positive integers or logical values.
The code can be modified accordingly as follows:
A = 10^(-4);
l = 250*10^(-6);
g = 0.1517;
e = 0.132205;
d = 0.142;
K = 2.34*10^(-12);
% Corrected use of parentheses
Yr = @(w) w*A*e*(d*(1-K)+g*K) / (l*((1-K)^2 +(g*K)^2));
fplot(Yr, [10,100], "r")
xlabel('Frequency')
ylabel('Conductance')
grid on
I hope this is the output you had in mind.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by