How can I programming Tally marks pictogram?

3 次查看(过去 30 天)
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 中查找有关 Line Plots 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by