Undefined operator '/' (PROBLEM SOLVED YEY)

Basically my excel file was the problem my numbers were somehow reserved as text thats why the operator didnnt work THAK YOU EVERYONE
i got thise code but when i try to run it i get this error: ((Undefined operator '/' for input arguments of type 'cell'.))
this is the code :
input_file = 'plan.xlsx';
% Read data from the specified sheet
data = readtable(input_file, 'Sheet', 'sheet1');
% Extract specific columns as arrays
L = data{:, 1}; % Assuming first column contains L values
D = data{:, 3}; % Assuming second column contains D values
k = data{:, 2}; % Assuming third column contains k values
% Initialize constants and result array
h = 50;
eta = zeros(size(L));
% Loop through each element to calculate eta
for i = 1:numel(L)
Li = L(i)/100; % Convert to meters
Di = D(i)/100; % Convert to meters
ki = k(i);
m = sqrt((4 * h)/(ki * Di));
eta(i) = tanh(m * Li)/(m * Li);
end
% Add eta as a new column in the table
data.eta = eta;
% Write the updated table back to the Excel file
writetable(data, input_file, 'Sheet', 'sheet1');

5 comentarios

Les Beckham
Les Beckham el 4 de Dic. de 2024
It would help to have the input data file plan.xlsx.
Aya
Aya el 4 de Dic. de 2024
Now it says this : The file extension '.' is not recognized.
Les Beckham
Les Beckham el 4 de Dic. de 2024
Editada: Les Beckham el 4 de Dic. de 2024
I didn't mean for you to add a period after the filename in your code, I meant for you to attach the file to your question, using the paperclip icon while you are editing the question. The period at the end of my comment is to mark the end of the sentence.
Stephen23
Stephen23 el 4 de Dic. de 2024
The cause is most likely that some of your spreadsheet data are non-numeric.
Please upload a sample data file by clicking the paperclip button.
Aya
Aya el 4 de Dic. de 2024
well sorry...my brain just lagged for a bit ... i fixed the problem it was the actual file in excel i dont know why but it was conserving my nymbers as a text that why matlab identified it as a text i had to convert the "text" to numbers again

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

Aya
el 4 de Dic. de 2024

Editada:

Aya
el 4 de Dic. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by