multiply large numeric two array and convert that array in Binary

fileId=fopen('sinlookup.txt','r');
line_num=0;
lineData='0';
while ~feof(fileId)
line_num=line_num+1;
lineData=fgetl(fileId);
disp(['Line ',num2str(line_num) , ': ' lineData ]);
end

댓글 수: 13

I have no idea what the question in your title (which is near unreadable) relates to the code you've posted. The code you've posted simply display each line of a text file.
Please write, a clear question in the box above, not in the title. Ideally provide examples of input(s) and desired output(s).
i have two different textfile with floating values no (sinlookup- 400 values ,signal - 30000 values ). i want to multiply those data to each other.
Dharti Vyas comment mistakenly posted as an answer moved here
fileId=fopen('sinlookup.txt','r');
line_num=0;
lineData='0';
while ~feof(fileId)
line_num=line_num+1;
lineData=fgetl(fileId);
disp(['Line ',num2str(line_num) , ': ' lineData ]);
end
fileId=fopen('signal.txt','r');
line_num=0;
lineData='0';
while ~feof(fileId)
line_num=line_num+1;
lineData=fgetl(fileId);
disp(['Line ',num2str(line_num) , ': ' lineData ]);
i have two different textfile with floating values no (sinlookup- 400 values ,signal - 30000 values ). i want to multiply those data to each other.
Guillaume
Guillaume 2018년 7월 25일
편집: Guillaume 2018년 7월 25일
Two question:
  • What does multiplying 400 values by 30000 values actually mean? What sort of result is expected?
  • Are your text files csv files?
its discrete modulating signals reading which is stored in textfile(signal.txt). i want to continuously multiply sine(which is stored in sinlookup.txt) and cos values to this signal numbers.
i want to continuously multiply sine and cos values to this signal numbers
I'm sorry I have no idea what that mean.
i want to multiply two array (this array is formed by reading two text file )which array consist a numeric value(floating point numbers --- 0.1112233552,-0.14567896......). 1_array= 400 * 1 ; 2_array = 30000 * 1
then i have to repeat 1st array till the both array has same size and then multiply array .after that output array will convert floating point number in to Binary block for sending.
I understand array. What I don't understand is what you mean by multiply when the two arrays are of different length.
Could you give a simple example of two shorts arrays of different size and the corresponding result, using valid matlab syntax? E.g. if
array1 = [0.1 -0.2 0.3 -0.4]
array2 = 1:12
What would be the desired result?
fileID = fopen('sinlookup.txt');
A = textscan(fileID,'%s');
fclose(fileID);
loadrange_1 = str2double(A{:,1})
fileID = fopen('signal.txt');
C = textscan(fileID,'%s');
fclose(fileID);
loadrange_2 = str2double(C{:,1})
b = repmat(A{:,1},75,1)
loadrange_1 = str2double(b)
c = [];
c = loadrange_1 .* loadrange_2 % multiply two array
display(c);
%convert this c_array which is having floating point number in to Binary number
this is my code but it is not work properly and in this code floating point number to binary conversion is not available because i dont know.
Could you give a simple example of two shorts arrays of different size and the corresponding result, using valid matlab syntax? E.g. if
array1 = [0.1 -0.2 0.3 -0.4]
array2 = 1:12
What would be the desired result?
array1 = [0.1 -0.2 0.3 -0.4]
array2 = 1:12
C = array1.*array2;
array1 =
0.1000 -0.2000 0.3000 -0.4000
array2 =
1 2 3 4 5 6 7 8 9 10 11 12
This error comes to run this code
Error using .* Matrix dimensions must agree.
array1 = [0.1 -0.2 0.3 -0.4].';
array2 = 1:12;
array3=0;
n_array2 = (array2).';
b = repmat(array1,[3 1]);
array3 = array3 + b * n_array2
Thank you this work perfectly.
I want help in further, how to convert this floating point number array into 32bit binary.
You have two arrays of different lengths, just like this small example has two arrays of different lengths. How would you like the two to be multiplied? Use the short example to illustrate the result you would want.

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

 채택된 답변

Walter Roberson
Walter Roberson 2018년 8월 2일

0 개 추천

I think you want to do filtering, which could be done by conv()

댓글 수: 2

hello sir, i have array of 65535*1 and my second array is 400*1.
a = repmat(A{:,1},164,1)
i am using this syntax repeat my this(400*1) array in to 164 times then it become (65600*1). ( 65535*1 ) this value is not multiple of 400 so what i do. cause this is the reading of signal which i stored in the buffer and for multiplication the size of array should be same. any other way to do this type of multiplication.
I would buffer(LargeArray, 400) which would create a 400 x 165 array. Then you can multiply it column by column by your 400 array. If you have R2016b or later, that would look like
output = buffer(LargeArray, length(SmallerArray)) .* SmallerArray(:);
This would produce a 400 x 165 array which you could reshape into a vector if you wanted to.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2018년 7월 25일

댓글:

2018년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by