Error using / Arguments must be numeric, char, or logical.
Mostrar comentarios más antiguos
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);
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 comentarios
KSSV
el 4 de Mayo de 2023
The error is clear. Check the path of the file you have given. Is the file present in the path given? What is the extneison of the file xls or xlsx?
Siddharth Bhutiya
el 4 de Mayo de 2023
If you are using R2023a and trying to do elementwise division on tables you need to use ./ instead of /
Gateeff(m,1) = refV(91,1) ./ GateV(91,1);
Since you are doing it on a single element, you might be better off using {} or dot+paren. as that would extract the data from your table and then do the division and put it back in Gateeff.
Gateeff{m,1} = refV{91,1} / GateV{91,1};
% OR
Gateeff.(1)(m) = refV.(1)(91) / GateV.(1)(91);
Walter Roberson
el 4 de Mayo de 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
el 4 de Mayo de 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.
Respuestas (1)
Walter Roberson
el 4 de Mayo de 2023
0 votos
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.
Categorías
Más información sobre Downloads en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!