need solution during trainning

조회 수: 136 (최근 30일)
NABARUN MAIKAP
NABARUN MAIKAP 2020년 5월 11일
댓글: Kalagatla 2024년 1월 25일
이 질문에 Walter Roberson 님이 플래그를 지정함
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.

답변 (10개)

VISHAL
VISHAL 2020년 5월 30일
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 2020년 5월 13일
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
DGM
DGM 2023년 4월 25일
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?

댓글을 달려면 로그인하십시오.


Hessel
Hessel 2020년 6월 1일
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 2020년 6월 12일
preprocds = transform(letterds,@scale)
function data = scale(data)
data.Time = (data.Time - data.Time(1))/1000;
data.X = 1.5*data.X;
end
  댓글 수: 2
Logesh B
Logesh B 2022년 1월 1일
answer is wrong
Prayas
Prayas 2022년 9월 15일
answer is wrong sir please solve it

댓글을 달려면 로그인하십시오.


L.J.
L.J. 2020년 6월 13일
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
JAMES S
JAMES S 2020년 8월 1일
Not solviing
구룽
구룽 2022년 10월 2일
task 2 says it's incorrect :(

댓글을 달려면 로그인하십시오.


Abdul Aziz Hisham Shubbak
Abdul Aziz Hisham Shubbak 2021년 4월 19일
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 2022년 6월 8일
이동: DGM 2023년 4월 25일
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
Luis
Luis 2023년 7월 16일
Thank you very much!

댓글을 달려면 로그인하십시오.


Md. Hasnat Karim
Md. Hasnat Karim 2023년 2월 15일
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
MAHESH BABU
MAHESH BABU 2023년 8월 26일
task 2 code error
Kalagatla
Kalagatla 2024년 1월 25일
task 2 erroe

댓글을 달려면 로그인하십시오.


Srivikasheetha
Srivikasheetha 2023년 7월 19일
편집: Walter Roberson 2023년 8월 26일
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 2023년 8월 24일
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
DGM
DGM 2023년 8월 24일
Your question is already answered above.
The course itself will also give you hints and solutions if you click on the links.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by