need solution during trainning

160 vues (au cours des 30 derniers jours)
NABARUN MAIKAP
NABARUN MAIKAP le 11 Mai 2020
Commenté : Kalagatla le 25 Jan 2024
Hello all, I am new in this community .I need help to solve the below problem. please help me..
statement : You can add a custom function at the end of your script. For data preprocessing, the function should take the data returned from the datastore as input. It should return the transformed data as output.
function dataout = functionName(datain)
% do something with datain
dataout = ...
end
Given script :
letterds = datastore("*_M_*.txt");
data = read(letterds);
data = scale(data);
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
Task ; -
Create a function called scale at the end of the script that performs the following operations:
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
Because these commands modify the variable data directly, your function should use data as both the input and output variable.
Note that the third line of the script calls the scale function. Your script won't run until this function has been created.
Also note that local functions must be at the end of a script. This means you will be editing the script sections out of order in this interaction. The section headings show which section of the script to edit in each task.

Réponses (10)

VISHAL
VISHAL le 30 Mai 2020
letterds = datastore("*_M_*.txt");
data = read(letterds);
data = scale(data);
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
end
  1 commentaire
Manoj Kumar M
Manoj Kumar M le 31 Mai 2020
is write answer

Connectez-vous pour commenter.


Ravi kumar
Ravi kumar le 13 Mai 2020
letterds = datastore("*_M_*.txt");
data = read(letterds);
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
data = scale(data);
  1 commentaire
DGM
DGM le 25 Avr 2023
Contrary to the instructions, this code performs all the tasks of the scale() function inline. Despite obviating the function call (and implementing no function), the nonexistent scale() function is still called, and it's called in a place where it would accomplish nothing even if it worked.
What's the point in posting answers that are demonstrably wrong?

Connectez-vous pour commenter.


Hessel
Hessel le 1 Juin 2020
you should put the "sacle" function at the end
letterds = datastore("*_M_*.txt");
data = read(letterds);
data = scale(data);
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
preprocds = transform(letterds,@scale)
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
end
  1 commentaire
BRAJ KISHOR VERMA
BRAJ KISHOR VERMA le 2 Juin 2020
show wrong result

Connectez-vous pour commenter.


Ali Al-nuaimi
Ali Al-nuaimi le 12 Juin 2020
preprocds = transform(letterds,@scale)
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
end
  2 commentaires
Logesh B
Logesh B le 1 Jan 2022
answer is wrong
Prayas
Prayas le 15 Sep 2022
answer is wrong sir please solve it

Connectez-vous pour commenter.


L.J.
L.J. le 13 Juin 2020
data = readall(preprocds);
plot(data.Time, data.Y)
The first line of code needs to be surpressed, so just be sure to add a ; to solve the issue :) good luck
  2 commentaires
JAMES S
JAMES S le 1 Août 2020
Not solviing
구룽
구룽 le 2 Oct 2022
task 2 says it's incorrect :(

Connectez-vous pour commenter.


Abdul Aziz Hisham Shubbak
Abdul Aziz Hisham Shubbak le 19 Avr 2021
last all ::
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
data.X = data.X - mean(data.X);
data.Y = data.Y - mean(data.Y);
end

Rhonnel S. Paculanan
Rhonnel S. Paculanan le 8 Juin 2022
Déplacé(e) : DGM le 25 Avr 2023
TASK 1
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
end
TASK 2
preprocds =transform( letterds , @scale ) % directly process the data storage
% Read all processed data
data =readall( preprocds );
plot( data . Time , data . Y )
TASK 3
preprocds = transform(letterds,@scale)
data = readall(preprocds)
plot(data.Time,data.Y)
TASK 4 (erase the content of Tasks 1 and paste this program)
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
data.X = data.X - mean(data.X);
data.Y = data.Y - mean(data.Y);
end
TASK 5 (erase the content of Tasks 4 and paste this program)
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
data.X = data.X - mean(data.X,"omitnan");
data.Y = data.Y - mean(data.Y,"omitnan");
end
  1 commentaire
Luis
Luis le 16 Juil 2023
Thank you very much!

Connectez-vous pour commenter.


Md. Hasnat Karim
Md. Hasnat Karim le 15 Fév 2023
put the scale function at the end of the script below the title "Tasks 1, 4, 5 ".
function data=scale(data)
data.Time=(data.Time-data.Time(1))/1000;
data.X = 1.5*data.X;
end
and write the following code for task 2
preprocds = transform(letterds,@scale)
  2 commentaires
MAHESH BABU
MAHESH BABU le 26 Août 2023
task 2 code error
Kalagatla
Kalagatla le 25 Jan 2024
task 2 erroe

Connectez-vous pour commenter.


Srivikasheetha
Srivikasheetha le 19 Juil 2023
Modifié(e) : Walter Roberson le 26 Août 2023
letterds = datastore("*_M_*.txt");
data = read(letterds);
% Your existing code
plot(data.X, data.Y)
axis equal
plot(data.Time, data.Y)
ylabel("Vertical position")
xlabel("Time")
% Define the custom function 'scale'
function dataout = scale(datain)
% Perform the operations on the input datain
datain.Time = (datain.Time - datain.Time(1)) / 1000;
datain.X = 1.5 * datain.X;
% Assign the transformed datain to dataout
dataout = datain;
end
% Call the scale function and assign the output to 'scaled_data'
scaled_data = scale(data);

RAMAKANT
RAMAKANT le 24 Août 2023
TASK
Create a function called scale at the end of the script that performs these operations:
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
Because these commands modify the variable data directly, your function must use data as both the input and output variable.
Note that the third line of the script calls the scale function. Your script won't run until this function has been created.
Also note that local functions must be at the end of a script. This means you must edit the script sections out of order in this activity. The section headings in the script show which section of the script to edit in each task.
what is answer given task
  1 commentaire
DGM
DGM le 24 Août 2023
Your question is already answered above.
The course itself will also give you hints and solutions if you click on the links.

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by