Matlab big matrix - windows

I'm trying to use matlab for the first time but I'm having a problem because the matrix I'm using is too big, I think.. I command I'm trying is:
m=[1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;169201]7;531456;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017;1692017]
And I'm getting the following error: Error: Unexpected MATLAB expression.
Does anyone have a solution for this?
Thanks in advance !

That matrix is tiny :-) Matlab can handle millions of elements per matrix.
However, on the second line, you have an extra bracket that ruins things:
...17;1692017;169201 ] 7;5...
Get rid of it, and you'll be fine!

Seems like you are trying to do a matrix, but typing its code wrongly. First, the ; separates lines; if you want to separaate columns in a row you have to use a space.
And you have two closing ], while you have only one opening [ which is clearly incorrect

Related

Background segmentation from multiple files.jpeg

I am trying to cut off background from currency notes. I used a blobsDemo.m codes I found here, used on coins.jpeg. it worked we quite well for me, on one note.
But when I tried it on multiple images, it returns results on just one note:
For k=1:16
JpegFileName=sprintf('%d.jpeg',k);
Fullfilename=fullfile('Folder',jpegfilename);
Imagedata=imread(Fullfilename)
Originalimage=rgb2gray(imagedata);
Subplot(4,4,k)
Imshow(original image);%displays all my 16 distinct images.
%but when I run
ThresholdValue(k)=100
Binaryimage=originalimage>threshold. value(k);
%it returns for one image.
End
What am I doing wrong please? I need help. Thankyou
for example if your resultant image is stored in variable "IM_out" then use IM_out(:,:,k)

Most efficient way to parse a file in Lua

I'm trying to figure out what is the most efficient way to parse data from a file using Lua. For example lets say I have a file (example.txt) with something like this in it:
0, Data
74, Instance
4294967295, User
255, Time
If I only want the numbers before the "," I could think of a few ways to get the information. I'd start out by getting the data with f = io.open(example.txt) and then use a for loop to parse each line of f. This leads to the heart of my question. What is the most efficient way to do this?
In the for loop I could use any of these methods to get the # before the comma:
line.find(regex)
line:gmatch(regex)
line:match(regex)
or Lua's split function
Has anyone run test for speed for these/other methods which they could point out as the fast way to parse? Bonus points if you can speak to speeds for parsing small vs. large files.
You probably want to use line:match("%d+").
line:find would work as well but returns more than you want.
line:gmatch is not what you need because it is meant to match several items in a string, not just one, and is meant to be used in a loop.
As for speed, you'll have to make your own measurements. Start with the simple code below:
for line in io.lines("example.txt") do
local x=line:match("%d+")
if x~=nil then print(x) end
end

Error when subtracting two negative numbers in ksh: “assignment requires lvalue”

I am trying to debug someone else's script:
The code line is:
y=$((${oldvalue[$x]}-${newvalue[$x]}))
y gets calculated fine as long as both sides are positive numbers. However, I have a production situation where they are both negative and the error I get is:
DEBUG Old value = -4144290000
DEBUG New value = -4009685000
script.sh: line 123: -4144290000--4009685000: assignment requires lvalue
I never would use ksh myself for even the simplest of calculations but I am in a position of production support and have to deal with a big ball of mud, I would use at least Perl/Python. Can anybody tell why this problem is happening and how to fix it?
Thanks
It needed spaces on both sides of the minus
y=$((${oldvalue[$x]} - ${newvalue[$x]}))

MATLAB - image huffman encoding

I have a homework in which i have to convert some images to grayscale and compress them using huffman encoding. I converted them to grayscale and then i tried to compress them but i get an error. I used the code i found here.
Here is the code i'm using:
A=imread('Gray\36.png');
[symbols,p]=hist(A,unique(A))
p=p/sum(p)
[dict,avglen]=huffmandict(symbols,p)
comp=huffmanenco(A,dict)
This is the error i get. It occurs at the second line.
Error using eps
Class must be 'single' or 'double'.
Error in hist (line 90)
bins = xx + eps(xx);
What am i doing wrong?
Thanks.
P.S. how can i find the compression ratio for each image?
The problem is that when you specify the bin locations (the second input argument of 'hist'), they need to be single or double. The vector A itself does not, though. That's nice because sometimes you don't want to convert your whole dataset from an integer type to floating precision. This will fix your code:
[symbols,p]=hist(A,double(unique(A)))
Click here to see this issue is discussed more in detail.
first, try :
whos A
Seems like its type must be single or double. If not, just do A = double(A) after the imread line. Should work that way, however I'm surprised hist is not doing the conversion...
[EDIT] I have just tested it, and I am right, hist won't work in uint8, but it's okay as soon as I convert my image to double.

Xcode Using Exponents

This is probably a simple question, but I a variable "side" to be divided by the square of the variable "curNum". Currently, my code for this looks like
side = inputNum/(curNum^2);
However, this gives me the error "Invalid operands to binary ^" How can I successfully use exponents?
Try
pow(curNum, 2)
Should work......

Resources