How can I programming Tally marks pictogram?

조회 수: 5 (최근 30일)
Jose Perez-Sanabria
Jose Perez-Sanabria 2020년 11월 29일
댓글: Rik 2020년 11월 29일
I am creating a Tally marks Pictogram with 5 cut options; But some numbers do not match the pictures that should have between one, two, three, four marks in the last one but they are divisible by 5.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; close all; clc;
%hf=figure('Position',[1 21 1366 670], ...
%"name","Tally marks Pictogram");
figure(1)
fs=30; fs2=20;
y = [1 2 3 4 5 6 7 8 9 10];
x = [5 6 7 8 9 10 11 12 13 14]
%x = [2 2 1 1 5 2 2 2 3 3];
%x=randi([0 20],1,10)
x=x/5;
xmax=ceil(max(x)); ymax=ceil(max(y));
im1=imread('tallymarks1.jpg');
im2=imread('tallymarks2.jpg');
im3=imread('tallymarks3.jpg');
im4=imread('tallymarks4.jpg');
im5=imread('tallymarks5.jpg');
axis([0 xmax 1 ymax+1])
axis square;
hold on
xPos = [1 0.1];
yPos = [1 0.1];
y2={"SEPT" "OCT" "NOV" "DEC" "JAN" "FEB" "MAR" "APR" "MAY" "JUN"};
set(gca,'ytick',y+0.5,'yticklabel',y2,"xticklabel",{});
set(gca,'fontsize',fs2,'fontweight','bold');
title("Tally Marks Pictogram", ...
"fontsize",fs)
for i = 1:numel(y)
yPos = yPos + 1;
if x(i)==0.2
image(xPos,yPos,im1)
endif
if x(i)==0.4
image(xPos,yPos,im2)
endif
if x(i)==0.6
image(xPos,yPos,im3)
endif
if x(i)==0.8
image(xPos,yPos,im4)
endif
for j = 1:fix(x(i))
image(xPos,yPos,im5)
xPos = xPos + 1;
absr=fix((x(i)-j)*5);
if(mod(absr,5)==1)
image(xPos,yPos,im1)
endif
if(mod(absr,5)==2)
image(xPos,yPos,im2)
endif
if(mod(absr,5)==3)
image(xPos,yPos,im3)
endif
if(mod(absr,5)==4)
image(xPos,yPos,im4)
endif
endfor
xPos = [1 0.1];
endfor
  댓글 수: 1
Rik
Rik 2020년 11월 29일
Your code is not formatted properly and is using invalid syntax. Change your code to something that is compatible with Matlab.

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

답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by