フィルターのクリア

MATLAB FUNDAMENTALS 11.4 Issue with y-data in MATLAB plot not being correct

61 ビュー (過去 30 日間)
Yueran
Yueran 2024 年 6 月 29 日 0:55
コメント済み: Cris LaPierre 2024 年 7 月 11 日 13:29
I am encountering an issue with the y-data in a MATLAB plot not being correct. Here are the steps to reproduce the issue:
  1. Load the data from movies.txt and releaseDates.txt using readtable.
  2. Modify the variable names in the release table.
  3. Ensure the Title variable in the release table matches the Title variable in the movies table.
  4. Join the two tables using the Title variable as the key.
  5. Convert the ReleaseDate to datetime format.
  6. Sort the movies table by ReleaseDate in ascending order.
  7. Plot AdjustedGross against ReleaseDate.I have confirmed there are no missing values in the AdjustedGross column and that the data types for ReleaseDate and AdjustedGross are correct. The plot is still not displaying the y-data as expected.
here is the code
This code sets up the activity.
movies = readtable("movies.txt","TextType","string");
release = readtable("releaseDates.txt","TextType","string");
movies
release.Properties.VariableNames(1) = "Title"
release.Properties.VariableNames(2) = "ReleaseDate"
release.Title = movies.Title
movies = join(movies, release, 'Keys', 'Title');
Task 1
movies = sortrows(movies,"ReleaseDate","ascend")
disp(movies.AdjustedGross)
plot(movies.ReleaseDate, movies.AdjustedGross,"-");
xlabel('Release Date');
ylabel('Adjusted Gross Revenue');
title('Adjusted Gross Revenue vs. Release Date');
  4 件のコメント
dpb
dpb 2024 年 6 月 30 日 13:31
movies = readtable("movies.txt","TextType","string");
Error using readtable (line 517)
Unable to find or open 'movies.txt'. Check the path and filename or file permissions.
release = readtable("releaseDates.txt","TextType","string");
movies
release.Properties.VariableNames(1) = "Title"
release.Properties.VariableNames(2) = "ReleaseDate"
release.Title = movies.Title
movies = join(movies, release, 'Keys', 'Title');
Nothing to be done here with the image, @Stephen23 means to attach the files "movies.txt" and "releaseDates.txt" themselves...
Mario Malic
Mario Malic 2024 年 7 月 1 日 12:50
You should have a Hint and See Solution button to find out where is your mistake.

サインインしてコメントする。

回答 (1 件)

Cris LaPierre
Cris LaPierre 2024 年 7 月 1 日 13:07
None of this code is necessary.
release.Properties.VariableNames(1) = "Title"
release.Properties.VariableNames(2) = "ReleaseDate"
release.Title = movies.Title
movies = join(movies, release, 'Keys', 'Title');
Remove it from the setup code and then submit the existing code for task 1. It should be correct.
  3 件のコメント
Yueran
Yueran 2024 年 7 月 8 日 20:59
I think my form is wrong. How can I solve this problem?
Cris LaPierre
Cris LaPierre 2024 年 7 月 11 日 13:29
Click Reset. That will return the task to its original state.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by