I can't load the lighthouse.mat image

4 ビュー (過去 30 日間)
Richard
Richard 2024 年 10 月 12 日
編集済み: DGM 2024 年 10 月 13 日
% Load the lighthouse image
load('lighthouse.mat');
% Display the original image
figure;
imshow(ww);
title('Original Lighthouse Image');
%Down-sample the image by factor of 2
p=2;
wp=ww(1:p:end, 1:p:end);
% Display the downsampled image
figure;
imshow(wp);
title(['Downsampled Image by a Factor of', num2str(p)])
error:
Error using load
Unable to find file or directory 'lighthouse.mat'.
Error in untitled5 (line 2)
load('lighthouse.mat');
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 10 月 12 日
編集済み: DGM 2024 年 10 月 13 日
Richard
Richard 2024 年 10 月 12 日
this one is the Exercise 2.3

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

回答 (2 件)

Venkat Siddarth Reddy
Venkat Siddarth Reddy 2024 年 10 月 12 日
Hi Richard,
It seems that the MATLAB is unable to find the "lighthouse" MAT file in its search path.
To resolve this issue, please make sure, either the file is in the current working directory or the file location is added to the MATLAB search path.
To learn more about adding a file location to MATLAB search path, please refer to the following documentation:
I hope it helps!

DGM
DGM 2024 年 10 月 13 日
編集済み: DGM 2024 年 10 月 13 日
I found this one (attached), but I can't be sure if it's the right one. I have to wonder, since it seems that you're expecting the file to contain a variable "ww", whereas Walter's thread expects the file to contain a variable "lighthouse". This one contains an array called "xx".
load lighthouse.mat
imshow(xx)
EDIT: This particular mat-file was saved in 2002 and appears to contain the same image (i.e. same photo content and array size/class) as some of the assignment summaries I've seen. I'm pretty sure this is a standard image, as I've seen it around. Even if there are mat-files with different variable names, this is probably equivalent.
Otherwise, you're probably supposed to download the file from somewhere associated with the book or online resource you're using.

Community Treasure Hunt

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

Start Hunting!

Translated by