Error using / Arguments must be numeric, char, or logical.

14 vues (au cours des 30 derniers jours)
Andika Asyuda
Andika Asyuda le 4 Mai 2023
Hi,
I am trying to run the folllowing code and get the following error message. Can anyone help to clarify my mistake and possible solution ? This problem should come from the very last line of code. As information, my input is a table with 181 rows and 5 columns.
error message:
Error using /
Arguments must be numeric, char, or logical.
Error in Henrique_Transistors_in_beaker_mod (line 72)
Gateeff(m,1) = refV(91,1)/GateV(91,1);
code:
input = 'C:\Users\aasyuda\Desktop\histamine\28April2023\scan_1\andikaAugatehistamine4electrode-1.xls';
opts = detectImportOptions(input);
Error using detectImportOptions
Unable to find or open 'C:\Users\aasyuda\Desktop\histamine\28April2023\scan_1\andikaAugatehistamine4electrode-1.xls'. Check the path and filename or file permissions.
T = 1e-7; %Assume 100 nm thick channel
W1 = 50e-6;
L5 = 500e-6;
DrainV = -0.2;
n=181;
m=33;
%Output Variables
OnOffRatio = zeros(33,1);
WTL = [];
AvgGateI = zeros(33,1);
ThresholdVoltage = zeros(33,1);
LastGateI = zeros(33,1);
Gateeff = zeros(33,1);
AbsoluteDrainI=zeros(n,m);
AbsoluteGateI=zeros(n,m);
ElectrolyteV=zeros(n,m);
opts.Sheet = 1;
CurrentRun = readtable(input,opts);
WTL = (W1*T)/L5;
GateV = CurrentRun.AV;
MaxGateV = max(GateV);
DrainI = CurrentRun(:,3);
AbsoluteDrainI(:,m) = abs(table2array(DrainI));
MaxDrainI(m,1) = max(AbsoluteDrainI(:,m));
MinDrainI(m,1) = min(AbsoluteDrainI(:,m));
OnOffRatio(m,1) = MaxDrainI(33,1)/MinDrainI(33,1);
GateI = CurrentRun(:,1);
AbsoluteGateI(:,m) = abs(table2array(GateI));
AvgGateI(m,1) = mean(AbsoluteGateI(:,m));
refV = CurrentRun(:,5);
ElectrolyteV(:,m) = abs(table2array(refV));
Gateeff(m,1) = refV(91,1)/GateV(91,1);
  4 commentaires
Walter Roberson
Walter Roberson le 4 Mai 2023
Good point about operations on table using the new R2023a facilities.
The user has marked they are using R2021b, so the new facilities do not apply to their situation, but your remark is a good reminder for people unfamiliar with the new facility.
Siddharth Bhutiya
Siddharth Bhutiya le 4 Mai 2023
Oh apologies, I did not notice that Andika was on R2021b. In that case, I think the way to go would be to use the second suggestion of doing {} or dot+paren subscripting to extract the data, do the division and the put it back.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 4 Mai 2023
The ability to do calculations directly on tables is not available until r2023a. Your refV is a table so refV(91,1) is a 1x1 table with one variable.
When you use () indexing on a table the result is a table.

Catégories

En savoir plus sur Downloads dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by