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

15 views (last 30 days)
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

Answers (1)

Pratyush Swain
Pratyush Swain on 21 May 2024
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.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!