need solution during trainning

129 visualizaciones (últimos 30 días)
NABARUN MAIKAP
NABARUN MAIKAP el 11 de Mayo de 2020
Comentada: Kalagatla el 25 de En. de 2024
Walter Roberson ha marcado con alerta este/a pregunta
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.

Respuestas (10)

VISHAL
VISHAL el 30 de Mayo de 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

Ravi kumar
Ravi kumar el 13 de Mayo de 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 comentario
DGM
DGM el 25 de Abr. de 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?

Iniciar sesión para comentar.


Hessel
Hessel el 1 de Jun. de 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

Ali Al-nuaimi
Ali Al-nuaimi el 12 de Jun. de 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 comentarios
Logesh B
Logesh B el 1 de En. de 2022
answer is wrong
Prayas
Prayas el 15 de Sept. de 2022
answer is wrong sir please solve it

Iniciar sesión para comentar.


L.J.
L.J. el 13 de Jun. de 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 comentarios
JAMES S
JAMES S el 1 de Ag. de 2020
Not solviing
구룽
구룽 el 2 de Oct. de 2022
task 2 says it's incorrect :(

Iniciar sesión para comentar.


Abdul Aziz Hisham Shubbak
Abdul Aziz Hisham Shubbak el 19 de Abr. de 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 el 8 de Jun. de 2022
Movida: DGM el 25 de Abr. de 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

Md. Hasnat Karim
Md. Hasnat Karim el 15 de Feb. de 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 comentarios
MAHESH BABU
MAHESH BABU el 26 de Ag. de 2023
task 2 code error
Kalagatla
Kalagatla el 25 de En. de 2024
task 2 erroe

Iniciar sesión para comentar.


Srivikasheetha
Srivikasheetha el 19 de Jul. de 2023
Editada: Walter Roberson el 26 de Ag. de 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 el 24 de Ag. de 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 comentario
DGM
DGM el 24 de Ag. de 2023
Your question is already answered above.
The course itself will also give you hints and solutions if you click on the links.

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by