Cody

Problem 46009. Pixel density

Solution 2765509

Submitted on 1 Aug 2020 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
filetext = fileread('ppi.m'); assert(isempty(strfind(filetext, 'eval')), 'Eval forbidden.'); assert(isempty(strfind(filetext, 'regexp')), 'Regexp forbidden.'); assert(isempty(strfind(filetext, '!')), 'Shell commands are forbidden.'); assert(isempty(strfind(filetext, 'mlock')), 'mlock is forbidden.'); assert(isempty(strfind(filetext, 'munlock')), 'munlock is forbidden.');

2   Pass
% tv screen d = 40; % 720p resolution w = 1280; h = 720; y_correct = 36.71; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 36.7151

3   Pass
% smartphone d = 5.5; % 720p resolution w = 1280; h = 720; y_correct = 267.02; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 267.0191

4   Pass
% tablet d = 7.5; % 720p resolution w = 1280; h = 720; y_correct = 195.81; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 195.8140

5   Pass
% monitor d = 17; % 1080p resolution w = 1920; h = 1080; y_correct = 129.58; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 129.5828

6   Pass
d = 17; % 2K resolution w = 2048; h = 1080; y_correct = 136.19; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 136.1953

7   Pass
d = 24; % UHD resolution w = 3840; h = 2160; y_correct = 183.57; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 183.5756

8   Pass
d = 24; % 4K resolution w = 4096; h = 2160; y_correct = 192.94; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 192.9433

9   Pass
d = 40; % 8K resolution w = 7680; h = 4320; y_correct = 220.29; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 220.2907

10   Pass
d = 50; % 16K resolution w = 15360; h = 8640; y_correct = 352.46; assert(abs(ppi(d, w, h) - y_correct) < 1e-2);

y = 352.4651

Suggested Problems

More from this Author5

Community Treasure Hunt

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

Start Hunting!