Effacer les filtres
Effacer les filtres

Can you please say why this is coming? can you please solve this?

1 vue (au cours des 30 derniers jours)
md sazzad
md sazzad le 21 Avr 2023
Commenté : Walter Roberson le 21 Avr 2023
function [Sample,Status,P0,RawP,RawT]=extract_data_P0(Nomfichier,SW_version)
%2 variable input 5 out put
opts=detectImportOptions('Capteur2125011.txt');
opts.DataLine=7;
opts.VariableNames={'SampleNumber','ReceivedFrame'};
RawData=(readtable(Nomfichier,opts));
Sample=table2array(RawData(:,1));
RawFrame=table2array(RawData(:,2));
%This code extracts data from a text file and converts it into two arrays
for i=1:length(RawFrame)
Status(i,1)=hex2dec(cat(2,RawFrame{i}(7:8),RawFrame{i}(10:11)));
P0(i,1)=hex2dec(cat(2,RawFrame{i}(19:20),RawFrame{i}(22:23)));
Error:
Error in extract_data_P0 (line 7)
RawData=(readtable(Nomfichier,opts));
  3 commentaires
Walter Roberson
Walter Roberson le 21 Avr 2023
My guess is that you tried to run this function by pressing the green Run button. When you use the Run button, that is the same thing as executing the function without any inputs, as if you had executed
extract_data_P0()
which would fail when it tried to use the Nomfichier variable.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 21 Avr 2023
You forgot to attach 'Capteur2125011.txt'. My guess is that you're either creating fields of "opts" that are not valid in readtable(), or you are not passing a string or character array in for Nomfichier, but we don't know because you also forgot to attach the actual error message (ALL THE RED TEXT, not just a snippet of it).
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by