How can I programming Tally marks pictogram?
1 view (last 30 days)
Show older comments
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/434123/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/434128/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/434133/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/434138/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/434143/image.jpeg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 Comment
Rik
on 29 Nov 2020
Your code is not formatted properly and is using invalid syntax. Change your code to something that is compatible with Matlab.
Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!