【发布时间】:2019-04-18 19:37:26
【问题描述】:
在 MATLAB 中,我想使用将参数输入作为结构体的函数对一组数据进行插值。但是,我收到一个错误。
我有一个结构:
fruit.apples = [3 4 2 3 4]
fruit.oranges = [1 0 0 0 0]
fruit.grapes = [2 3 2 2 1]
所以我想把这个水果结构插入到samples = 20;`
这是我的代码:
function [output] = fruitbasket (fruit, samples)
sampleLength = linspace(1, numel(data), samples + numel(data));
sampleLength = sampleLength';
output = interp1(data, sampleLength);
我希望的输出是在水果篮结构中用 25 个苹果、25 个橙子和 25 个葡萄对每个数组进行插值。如果将结构替换为变量,则代码可以工作,但我需要使用结构,以便可以将多个输入传递给函数。
【问题讨论】:
标签: matlab structure interpolation