小编shl*_*omi的帖子

在jquery/js中将数组中的元素插入表中

我有一个名为reservations.js的js文件,在这个文件中我有一个保留数组,如:

var reservations = [
  { "HotelId": "01", "HotelName": "SPA", "ReservNum": "0166977", "Guest Name": "Jonny", "Room": null, "Type": "SUIT", "Rooms": "1", "Board": "BB", "Status": "IH", "Pax": "2,0,0,0", "Arrival": "07/08/12", "Departure": "09/08/12", "AgentDesc": "FIT", "AgentCode": "FIT", "Group": null, "Balance": "0", "Requests": "", "Remarks": null, "Fit/Group": "FIT", "ReturnGuestName": "", "StatusColor": "LightCoral" },
  { "HotelId": "01", "HotelName": "SPA", "ReservNum": "H000192", "Guest Name": null, "Room": null, "Type": "Folio", "Rooms": "0", "Board": "", "Status": "IH", "Pax": "0,0,0,0", "Arrival": "07/08/12", "Departure": "10/09/12", "AgentDesc": "movies", "AgentCode": "001", …
Run Code Online (Sandbox Code Playgroud)

javascript arrays jquery

7
推荐指数
1
解决办法
2万
查看次数

如何在matlab中读取文件?

我有一个txt文件,文件的内容是数字行,每行有5个浮点数,每个数字之间用逗号分隔.例:

1.1,12,1.42562,3.5,2.2

2.1,3.3,3,3.333,3.75

如何在matlab中将文件内容读入矩阵?到目前为止我有这个:

fid = fopen('file.txt');
comma  = char(',');
A = fscanf(fid, ['%f', comma]);
fclose(fid);
Run Code Online (Sandbox Code Playgroud)

问题是它只给我第一行,当我尝试写AI的内容时得到这个:1.0e + 004*一些数字

有谁可以帮助我吗?我想对于文件我需要在循环中读取它,但我不知道如何.

编辑:还有一个问题:当我输出AI时,得到这个:

A =

1.0e+004 *
4.8631         0         0         0    0.0001
4.8638   -0.0000   -0.0000    0.0004    0.0114
4.8647   -0.0000   -0.0000    0.0008    0.0109
Run Code Online (Sandbox Code Playgroud)

我想要文件中的相同值在矩阵中,如何使数字成为常规浮点数而不是像这样格式化?或者矩阵中的数字是否实际浮动,但输出只是这样显示?

matlab file matrix

6
推荐指数
2
解决办法
3万
查看次数

如何在python中计算平均值?

我有一个列表,我想计算她的值的平均值(平均值?).当我这样做:

import numpy as np #in the beginning of the code

goodPix = ['96.7958', '97.4333', '96.7938', '96.2792', '97.2292']
PixAvg = np.mean(goodPix)
Run Code Online (Sandbox Code Playgroud)

我收到此错误代码:

ret = um.add.reduce(arr, axis=axis, dtype=dtype, out=out, keepdims=keepdims)
Run Code Online (Sandbox Code Playgroud)

TypeError: cannot perform reduce with flexible type

我试图找到一些帮助,但没有找到有用的东西

谢谢你们.

python average list mean

6
推荐指数
1
解决办法
3635
查看次数

获取日期并将其保存为文件名python

我有一些图表,我在python中做.

最后我将绘图保存为png文件.这是代码:

plt.scatter(LuxCoordinates, finalPix, linewidths=1)
plt.sca
plt.grid(axis)
plt.xlabel('Ambient', color='r');
plt.ylabel('Depth Grows', color='r'); # grayscale color
plt.title(PngName, color='b');
savefig(PngName+'.png'); #PngName is the name of the file that the user gives in argv
Run Code Online (Sandbox Code Playgroud)

这项工作很好,它保存了一个文件,名称PngName.png(其中PngName是用户决定的)

现在我想将该名称添加到当前日期.我试过这样做:

date = time.strftime("%d/%m/%Y")
plt.scatter(LuxCoordinates, finalPix, linewidths=1)
plt.sca
plt.grid(axis)
plt.xlabel('Ambient', color='r');
plt.ylabel('Depth Grows', color='r'); # grayscale color
plt.title(PngName, color='b');
savefig(PngName+'_'+date+'.png')
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我收到此错误消息:

filename_or_obj = open(filename_or_obj,'wb')IOError:[Errno 2]没有这样的文件或目录:'05/12/2013.png'

您可以看到日期变量获取日期.(当我将它打印到屏幕上时,我看到了日期)

有什么问题,如何解决?

谢谢!

python date save

5
推荐指数
1
解决办法
1161
查看次数

计算python中的值的数量

我有一个列表看起来像这样:

Lux = ([ 0 0 0 0 0 120 120 120 120 120 240 240 240 240 240 0 0 0 0 0 120 120 120 120 120])
Run Code Online (Sandbox Code Playgroud)

我想要计算我有多少零,但只有14个地方,然后说到16个地方答案将在这种情况下2.我知道计数函数统计所有的外观.我怎么能这样做,但是没有循环?当我已经处于两个循环中时,我想要这个,并且不想添加另一个循环.

谢谢.

python list count

3
推荐指数
1
解决办法
197
查看次数

matlab-return矩阵

我需要帮助,如何从matlab中的函数返回矩阵?我有一个带零的矩阵(大小为NxN).我发送矩阵到一些功能来更新她.如何返回更新的矩阵?

在代码中:

matrix = zeros(size); %put zeros
updateMatrix(radius,x0,y0,matrix);%call to function

function updateMatrix(radius,x0,y0,matrix)
    update the matrix
end

continue the prog with the updated matrix
Run Code Online (Sandbox Code Playgroud)

我只需要返回更新的矩阵,我不会更改其他变量.

我试着这样做:

matrix = zeros(size); %put zeros
matrix=updateMatrix(radius,x0,y0,matrix);%call to function

function [matrix]=updateMatrix(radius,x0,y0,matrix)
    update the matrix
end

continue the prog with the updated matrix
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

谢谢!

arrays matlab return matrix

1
推荐指数
1
解决办法
3113
查看次数

标签 统计

python ×3

arrays ×2

list ×2

matlab ×2

matrix ×2

average ×1

count ×1

date ×1

file ×1

javascript ×1

jquery ×1

mean ×1

return ×1

save ×1