how to resolve fprintf error when dealing with whole numbers?
G’day,
I have a matirx containing the following values
a = [16.0541, 17];
I am trying to write these types of data along with many other variables to a json file. However, I have encountered a problem with the second value, which produces an empty cell. Here’s a simple test
for i = 1:2
fprintf(‘n%s’,’"values":{‘);
fprintf(‘n%s’,’"min":’);
fprintf(‘%s’,a(i));
fprintf(‘%s’,’,’);
fprintf(‘n%s’,’"max":’);
fprintf(‘%s’,a(i));
fprintf(‘n%s’,’},’);
end
I am assuming it has something to do with the second value being a whole number. How do I resolve this issue?
Thanks in advance.
JonG’day,
I have a matirx containing the following values
a = [16.0541, 17];
I am trying to write these types of data along with many other variables to a json file. However, I have encountered a problem with the second value, which produces an empty cell. Here’s a simple test
for i = 1:2
fprintf(‘n%s’,’"values":{‘);
fprintf(‘n%s’,’"min":’);
fprintf(‘%s’,a(i));
fprintf(‘%s’,’,’);
fprintf(‘n%s’,’"max":’);
fprintf(‘%s’,a(i));
fprintf(‘n%s’,’},’);
end
I am assuming it has something to do with the second value being a whole number. How do I resolve this issue?
Thanks in advance.
Jon G’day,
I have a matirx containing the following values
a = [16.0541, 17];
I am trying to write these types of data along with many other variables to a json file. However, I have encountered a problem with the second value, which produces an empty cell. Here’s a simple test
for i = 1:2
fprintf(‘n%s’,’"values":{‘);
fprintf(‘n%s’,’"min":’);
fprintf(‘%s’,a(i));
fprintf(‘%s’,’,’);
fprintf(‘n%s’,’"max":’);
fprintf(‘%s’,a(i));
fprintf(‘n%s’,’},’);
end
I am assuming it has something to do with the second value being a whole number. How do I resolve this issue?
Thanks in advance.
Jon fprintf MATLAB Answers — New Questions