need solution during trainning

147 Ansichten (letzte 30 Tage)
NABARUN MAIKAP
NABARUN MAIKAP am 11 Mai 2020
Kommentiert: Kalagatla am 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.

Antworten (10)

VISHAL
VISHAL am 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

Ravi kumar
Ravi kumar am 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 Kommentar
DGM
DGM am 25 Apr. 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?

Melden Sie sich an, um zu kommentieren.


Hessel
Hessel am 1 Jun. 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 am 12 Jun. 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 Kommentare
Logesh B
Logesh B am 1 Jan. 2022
answer is wrong
Prayas
Prayas am 15 Sep. 2022
answer is wrong sir please solve it

Melden Sie sich an, um zu kommentieren.


L.J.
L.J. am 13 Jun. 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 Kommentare
JAMES S
JAMES S am 1 Aug. 2020
Not solviing
구룽
구룽 am 2 Okt. 2022
task 2 says it's incorrect :(

Melden Sie sich an, um zu kommentieren.


Abdul Aziz Hisham Shubbak
Abdul Aziz Hisham Shubbak am 19 Apr. 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 am 8 Jun. 2022
Verschoben: DGM am 25 Apr. 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 am 15 Feb. 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 Kommentare
MAHESH BABU
MAHESH BABU am 26 Aug. 2023
task 2 code error
Kalagatla
Kalagatla am 25 Jan. 2024
task 2 erroe

Melden Sie sich an, um zu kommentieren.


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

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by